rt3x.de NoPaste

Shell Quote of the day

This is a nopaste service, powered by Flying Paste.

Author: Malte Bublitz
Language/File type: Bash script

Description

Display a Doctor Who quote¹ on even days, and a Brooklyn 99 quote² on odd; but only on the first TTY.

1: https://aur.archlinux.org/cgit/aur.git/tree/doctorwho-new-series?h=fortune-mod-doctorwho-new-series
2: https://aur.archlinux.org/cgit/aur.git/tree/brooklyn-nine-nine?h=fortune-mod-brooklyn-nine-nine

Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 
# Display a Doctor Who quote on even days, and a Brooklyn 99 quote on odd
# 
doctor_who_quote() {
	FORTUNE_DB="doctorwho-new-series"
	FORTUNE_MAX_LENGTH="600"
	fortune -s -n ${FORTUNE_MAX_LENGTH} ${FORTUNE_DB}
}
brooklyn_nine_nine_quote() {
	FORTUNE_DB="brooklyn-nine-nine"
	FORTUNE_MAX_LENGTH="600"
	fortune -s -n ${FORTUNE_MAX_LENGTH} ${FORTUNE_DB}
}
if [[ $TTY == "/dev/tty1" || $TTY == "/dev/pts/0" ]]; then
	day_of_month=$(date +%d)
	if [[ $((day_of_month % 2)) -eq 0 ]]; then
		doctor_who_quote
	else
		brooklyn_nine_nine_quote
	fi
	echo
fi