2015-07-03 00:27:48 +00:00
|
|
|
# chucknorris: Chuck Norris fortunes
|
|
|
|
|
2015-02-21 23:24:07 +00:00
|
|
|
# Automatically generate or update Chuck's compiled fortune data file
|
2015-07-03 00:27:48 +00:00
|
|
|
# $0 must be used outside a local function. This variable name is unlikly to collide.
|
|
|
|
CHUCKNORRIS_PLUGIN_DIR=${0:h}
|
|
|
|
|
|
|
|
() {
|
|
|
|
local DIR=$CHUCKNORRIS_PLUGIN_DIR/fortunes
|
2015-02-21 23:24:07 +00:00
|
|
|
if [[ ! -f $DIR/chucknorris.dat ]] || [[ $DIR/chucknorris.dat -ot $DIR/chucknorris ]]; then
|
2015-07-03 00:27:48 +00:00
|
|
|
# For some reason, Cygwin puts strfile in /usr/sbin, which is not on the path by default
|
|
|
|
local strfile=strfile
|
|
|
|
if ! which strfile &>/dev/null && [[ -f /usr/sbin/strfile ]]; then
|
|
|
|
strfile=/usr/sbin/strfile
|
|
|
|
fi
|
|
|
|
if which $strfile &> /dev/null; then
|
|
|
|
$strfile $DIR/chucknorris $DIR/chucknorris.dat >/dev/null
|
|
|
|
else
|
|
|
|
echo "[oh-my-zsh] chucknorris depends on strfile, which is not installed" >&2
|
|
|
|
echo "[oh-my-zsh] strfile is often provided as part of the 'fortune' package" >&2
|
|
|
|
fi
|
2015-02-21 23:24:07 +00:00
|
|
|
fi
|
2015-02-20 04:53:48 +00:00
|
|
|
|
2015-02-21 23:24:07 +00:00
|
|
|
# Aliases
|
|
|
|
alias chuck="fortune -a $DIR"
|
|
|
|
alias chuck_cow="chuck | cowthink"
|
2015-07-03 00:27:48 +00:00
|
|
|
}
|
2015-01-30 19:31:05 +00:00
|
|
|
|
2015-07-03 00:27:48 +00:00
|
|
|
unset CHUCKNORRIS_PLUGIN_DIR
|