mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-18 03:40:08 +00:00
a2e01e9a87
Gives a better error message than "command not found: strfile", because it's not obvious to many users that strfile is part of fortune. Also handles the weird /usr/sbin install location for strfile on Cygwin.
28 lines
976 B
Bash
28 lines
976 B
Bash
# chucknorris: Chuck Norris fortunes
|
|
|
|
# Automatically generate or update Chuck's compiled fortune data file
|
|
# $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
|
|
if [[ ! -f $DIR/chucknorris.dat ]] || [[ $DIR/chucknorris.dat -ot $DIR/chucknorris ]]; then
|
|
# 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
|
|
fi
|
|
|
|
# Aliases
|
|
alias chuck="fortune -a $DIR"
|
|
alias chuck_cow="chuck | cowthink"
|
|
}
|
|
|
|
unset CHUCKNORRIS_PLUGIN_DIR
|