d8b3e115e968225b5a0b999ea9292ac0263d5586
- Author
- Luiz Pericolo <luiz.barbosa@hotelurbano.com.br>
- Committer
- Marc Cornellà <hello@mcornella.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/hitchhiker/.gitignore b/plugins/hitchhiker/.gitignore
2new file mode 100644
3index 0000000000000000000000000000000000000000..63c2b54c4506933550a3b10522cb1d3fb5c51d30
4--- /dev/null
5+++ b/plugins/hitchhiker/.gitignore
6@@ -0,0 +1 @@
7+fortunes/hitchhiker.dat
8diff --git a/plugins/hitchhiker/README.md b/plugins/hitchhiker/README.md
9new file mode 100644
10index 0000000000000000000000000000000000000000..d12a1e93f48de5ab5eb203bbb9f260c781fbc83b
11--- /dev/null
12+++ b/plugins/hitchhiker/README.md
13@@ -0,0 +1,44 @@
14+# hitchhiker
15+
16+This plugin adds quotes from The Hitchhiker's Guide to the Galaxy, from Douglas Adams.
17+
18+To use it, add `hitchhiker` to the plugins array in your zshrc file:
19+
20+```zsh
21+plugins=(... hitchhiker)
22+```
23+
24+## Aliases
25+
26+- `hitchhiker`: displays a quote from the book using `fortune`.
27+- `hitchhiker_cow`: displays a quote from the book using `cowthink`.
28+
29+```console
30+$ hitchhiker_cow
31+ _______________________________________
32+( "OK, so ten out of ten for style, but )
33+( minus several million for good )
34+( thinking, yeah? " )
35+ ---------------------------------------
36+ o ^__^
37+ o (oo)\_______
38+ (__)\ )\/\
39+ ||----w |
40+ || ||
41+```
42+
43+## Requirements
44+
45+- `fortune` and `strfile`.
46+- `cowthink` if using the `hitchhiker_cow` command.
47+
48+## Credits
49+
50+Fortune file: Andreas Gohr <andi@splitbrain.org> ([splitbrain.org](https://www.splitbrain.org/projects/fortunes/hg2g))
51+
52+Spelling and formatting fixes: grok@resist.ca
53+
54+Original quotes from:
55+
56+- https://web.archive.org/web/20120106083254/http://tatooine.fortunecity.com/vonnegut/29/hitch/parhaat.html
57+- https://web.archive.org/web/20011112065737/http://www-personal.umd.umich.edu/~nhughes/dna/faqs/quotedir.html
58diff --git a/plugins/hitchhiker/fortunes/hitchhiker b/plugins/hitchhiker/fortunes/hitchhiker
59new file mode 100644
60index 0000000000000000000000000000000000000000..825b86cd60be4de23de83761e3ed88d647ef48c9
61--- /dev/null
62+++ b/plugins/hitchhiker/fortunes/hitchhiker
63@@ -0,0 +1,275 @@
64diff --git a/plugins/hitchhiker/hitchhiker.plugin.zsh b/plugins/hitchhiker/hitchhiker.plugin.zsh
65new file mode 100644
66index 0000000000000000000000000000000000000000..aeafaf01ef6e49a779737437f0609b05545f72f2
67--- /dev/null
68+++ b/plugins/hitchhiker/hitchhiker.plugin.zsh
69@@ -0,0 +1,23 @@
70+HITCHHIKER_DIR="${0:h}/fortunes"
71+
72+# Aliases
73+alias hitchhiker="fortune -a $HITCHHIKER_DIR"
74+alias hitchhiker_cow="hitchhiker | cowthink"
75+
76+() {
77+ # Don't generate hitchhiker.dat if it exists and is up-to-date
78+ if [[ -f "$HITCHHIKER_DIR/hitchhiker.dat" ]] && ! [[ "$HITCHHIKER_DIR/hitchhiker.dat" -ot "$HITCHHIKER_DIR/hitchhiker" ]]; then
79+ return
80+ fi
81+
82+ # If strfile is not found: some systems install strfile in /usr/sbin but it's not in $PATH
83+ if ! command -v strfile &>/dev/null && ! [[ -f /usr/sbin/strfile ]]; then
84+ echo "[oh-my-zsh] hitchhiker depends on strfile, which is not installed" >&2
85+ echo "[oh-my-zsh] strfile is often provided as part of the 'fortune' package" >&2
86+ return
87+ fi
88+
89+ "${commands[strfile]:-/usr/sbin/strfile}" "$HITCHHIKER_DIR/hitchhiker" "$HITCHHIKER_DIR/hitchhiker.dat" >/dev/null
90+}
91+
92+unset HITCHHIKER_DIR