plugins/chucknorris: Add automatic updating of the compiled fortune data file. Use local variable for readability, and anonymous function to provide a scope for the local variable.

This commit is contained in:
Andrew Janke 2015-02-19 23:53:48 -05:00
parent 9bf19603d3
commit 5f90781783

View File

@ -1,6 +1,12 @@
if [ ! -f $ZSH/plugins/chucknorris/fortunes/chucknorris.dat ]; then
strfile $ZSH/plugins/chucknorris/fortunes/chucknorris $ZSH/plugins/chucknorris/fortunes/chucknorris.dat
fi
() {
# Automatically generate or update Chuck's compiled fortune data file
local fdir=$ZSH/plugins/chucknorris/fortunes
if [[ ! -f $fdir/chucknorris.dat ]] || [[ $fdir/chucknorris.dat -ot $fdir/chucknorris ]]; then
strfile $fdir/chucknorris $fdir/chucknorris.dat
fi
# Aliases
alias chuck="fortune -a $fdir"
alias chuck_cow="chuck | cowthink"
}
alias chuck="fortune -a $ZSH/plugins/chucknorris/fortunes"
alias chuck_cow="chuck | cowthink"