mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-04-24 04:29:25 +02:00
Hitchhiker's guide to the galaxy fortune plugin
This commit is contained in:
parent
1e90f3618f
commit
e5c8d36406
4 changed files with 698 additions and 0 deletions
28
plugins/hitchhiker/hitchhiker.plugin.zsh
Normal file
28
plugins/hitchhiker/hitchhiker.plugin.zsh
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# hitchhiker: Hitchhiker's Guide to the Galaxy fortunes
|
||||
|
||||
# Automatically generate or update Hitchhicker's compiled fortune data file
|
||||
# $0 must be used outside a local function. This variable name is unlikly to collide.
|
||||
HITCHHIKER_PLUGIN_DIR=${0:h}
|
||||
|
||||
() {
|
||||
local DIR=$HITCHHIKER_PLUGIN_DIR/fortunes
|
||||
if [[ ! -f $DIR/hitchhiker.dat ]] || [[ $DIR/hitchhiker.dat -ot $DIR/hitchhiker ]]; 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/hitchhiker $DIR/hitchhiker.dat >/dev/null
|
||||
else
|
||||
echo "[oh-my-zsh] hitchhiker 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 hitchhiker="fortune -a $DIR"
|
||||
alias hitchiker_cow="chuck | cowthink"
|
||||
}
|
||||
|
||||
unset HITCHHIKER_PLUGIN_DIR
|
||||
Loading…
Add table
Add a link
Reference in a new issue