-
Notifications
You must be signed in to change notification settings - Fork 0
/
usr.local.bin.unfortunate.sh
executable file
·64 lines (50 loc) · 1.64 KB
/
usr.local.bin.unfortunate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
set -eu
help_intro() {
cat <<ENDUSAGE
Welcome to $(rainbow unfortunate)!
The default fortune database is: "$FORTUNE_FILE".
The pretty colors are from the $(rainbow rainbow) command.
A nice way to run $(rainbow fortune) is with a command like this:
$(rainbow 'fortune | fold -s | rainbow')
Run $(rainbow unfortunate fortunes) to see a list of fortune databases
and how you can get fortunes from them.
Run $(rainbow unfortunate usage) to see other help topics.
The default $(rainbow fortune) database is from
$(rainbow THE INVISIBLE STATES OF AMERICA A TOURISM GUIDE BY UEL ARAMCHEK)
<https://github.com/mrled/fortunate/tree/master/invisiblestates>
Here's a nice fortune to get you started, randomly selected on each run:
$(fortune | fold -s | rainbow)
ENDUSAGE
}
help_fortunes() {
cat <<ENDUSAGE
There are other fortune databases available at $(rainbow "$FORTUNE_DIR"):
$(ls -AlF "$FORTUNE_DIR" | rainbow)
Use them by passing their name to the $(rainbow fortune) command:
$(rainbow "fortune $FORTUNE_DIR/mrled.tweets | fold -s | rainbow")
ENDUSAGE
}
help_usage() {
cat <<ENDUSAGE
Usage: $(rainbow unfortunate [SUBCOMMAND...]): Help topics for this emulated Linux system
$(rainbow unfortunate usage)
Show this help
$(rainbow unfortunate intro)
Show intro text
$(rainbow unfortunate fortunes)
Show list of fortune databases and how to retrieve fortunes from them
ENDUSAGE
}
if test $# -lt 1; then
help_usage
exit 1
fi
while test $# -gt 0; do
case "$1" in
usage) help_usage; shift;;
intro) help_intro; shift;;
fortunes) help_fortunes; shift;;
*) help_usage; exit 1;;
esac
done