Unverified Commit d8b3e115 authored by Luiz Pericolo's avatar Luiz Pericolo Committed by Marc Cornellà
Browse files

feat(plugins): add hitchhiker plugin (#5117)

parent 02d07f3e
fortunes/hitchhiker.dat
# hitchhiker
This plugin adds quotes from The Hitchhiker's Guide to the Galaxy, from Douglas Adams.
To use it, add `hitchhiker` to the plugins array in your zshrc file:
```zsh
plugins=(... hitchhiker)
```
## Aliases
- `hitchhiker`: displays a quote from the book using `fortune`.
- `hitchhiker_cow`: displays a quote from the book using `cowthink`.
```console
$ hitchhiker_cow
_______________________________________
( "OK, so ten out of ten for style, but )
( minus several million for good )
( thinking, yeah? " )
---------------------------------------
o ^__^
o (oo)\_______
(__)\ )\/\
||----w |
|| ||
```
## Requirements
- `fortune` and `strfile`.
- `cowthink` if using the `hitchhiker_cow` command.
## Credits
Fortune file: Andreas Gohr <andi@splitbrain.org> ([splitbrain.org](https://www.splitbrain.org/projects/fortunes/hg2g))
Spelling and formatting fixes: grok@resist.ca
Original quotes from:
- https://web.archive.org/web/20120106083254/http://tatooine.fortunecity.com/vonnegut/29/hitch/parhaat.html
- https://web.archive.org/web/20011112065737/http://www-personal.umd.umich.edu/~nhughes/dna/faqs/quotedir.html
This diff is collapsed.
HITCHHIKER_DIR="${0:h}/fortunes"
# Aliases
alias hitchhiker="fortune -a $HITCHHIKER_DIR"
alias hitchhiker_cow="hitchhiker | cowthink"
() {
# Don't generate hitchhiker.dat if it exists and is up-to-date
if [[ -f "$HITCHHIKER_DIR/hitchhiker.dat" ]] && ! [[ "$HITCHHIKER_DIR/hitchhiker.dat" -ot "$HITCHHIKER_DIR/hitchhiker" ]]; then
return
fi
# If strfile is not found: some systems install strfile in /usr/sbin but it's not in $PATH
if ! command -v strfile &>/dev/null && ! [[ -f /usr/sbin/strfile ]]; then
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
return
fi
"${commands[strfile]:-/usr/sbin/strfile}" "$HITCHHIKER_DIR/hitchhiker" "$HITCHHIKER_DIR/hitchhiker.dat" >/dev/null
}
unset HITCHHIKER_DIR
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment