forked from ohmyzsh/ohmyzsh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ohmyzsh#4121 from apjanke/chucknorris-check-for-fo…
…rtune chucknorris: check for fortune/strfile dependency
- Loading branch information
Showing
1 changed file
with
25 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,28 @@ | ||
if [ ! -f $ZSH/plugins/chucknorris/fortunes/chucknorris.dat ]; then | ||
strfile $ZSH/plugins/chucknorris/fortunes/chucknorris $ZSH/plugins/chucknorris/fortunes/chucknorris.dat | ||
# 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 | ||
|
||
alias chuck="fortune -a $ZSH/plugins/chucknorris/fortunes" | ||
# Aliases | ||
alias chuck="fortune -a $DIR" | ||
alias chuck_cow="chuck | cowthink" | ||
} | ||
|
||
unset CHUCKNORRIS_PLUGIN_DIR |