From: Samir Benmendil Date: Tue, 19 Dec 2017 00:56:20 +0000 (+0000) Subject: zsh: Calendar Facts MOTD X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/8a3e572819bb1a316bd9841db46b6d66fb2c85ff zsh: Calendar Facts MOTD See https://www.xkcd.com/1930/ --- diff --git a/zsh/lib/motd.zsh b/zsh/lib/motd.zsh index ca345fa..24eef9c 100644 --- a/zsh/lib/motd.zsh +++ b/zsh/lib/motd.zsh @@ -10,6 +10,78 @@ msg() print "$fg_bold[white]$1$reset_color\n$2\n" } -short "[count][\"x]gr{motion}" 'Replace {motion} text with the contents of register x.' -short "gn" "Like \`n\`, but start Visual mode to select the match. If an operator is pending, operates on the match." -short "K" "If ft=gitrebase => show diff of commit" +function () { + function c() + { + local rand=$(od -An -t u1 -N1 /dev/urandom) + local idx=$((1 + (rand % $#))) + echo ${@[$idx]} + } + + recurring_event=( + "the $(c fall spring) equinox" + "the $(c winter summer) $(c solstice olympics)" + "the $(c erliest latest) $(c sunrise sunset)" + "the daylight $(c saving savings) time" + "the leap $(c day year)" + "easter" + "the $(c harvest super blood) moon" + "Toyota Truck Month" + "Shark Week" + ) + drifters=( + sun + moon + zodiac + "$(c gregorian mayan lunar iPhone) calendar" + "atomic clock in Colorado" + ) + unusual_manner=( + "happens $(c earlier later "at the wrong time") every year" + "drifts out of sync with the $(c ${drifters[@]})" + "might $(c "not happen" "happen twice") this year" + ) + ions_and_ities=(precession libration nutation libation eccentricity obliquity) + iees_and_itees=( + moon + sun + "earth's axis" + equator + "prime meridian" + "$(c "international date" "Mason-Dixon") line" + ) + + phenomenon=( + "time zone legislation in $(c Indiana Arizona Russia)" + "a decree by the Pope in the 1500s" + "$(c ${ions_and_ities[@]}) of the $(c ${iees_and_itees[@]})" + "magnetic field reversal" + "an arbitrary decision by $(c "Benjamin Franklin" "Isaac Newton" "FDR")" + ) + excuse=( + "will never happen" + "actually makes things worse" + "is stalled in congress" + "might be unconstitutional" + ) + statement=( + "it causes a predictable increase in car accidents" + "that's why we have leap seconds" + "scientists are really worried" + "it was even more extreme during the $(c "bronze age" "ice age" cretaceous 1990s)" + "there's a proposal to fix it, but it $(c ${excuse[@]})" + "it's getting worse and no one knows why" + ) + consequence=( + "causes huge headaches for software developers" + "is taken advantage of by high-speed traders" + "triggered the 2003 Northeast Blackout" + "has to be corrected for by GPS satellites" + "is now recognized as a major cause of World War I" + ) + autoload zmathfunc + which zsh_math_func_min >/dev/null || zmathfunc + echo -n "Did you know that $(c ${recurring_event[@]}) $(c ${unusual_manner[@]})" \ + "because of $(c ${phenomenon[@]})? Apparently $(c ${statement[@]}). " \ + "While it may seem like trivia, it $(c ${consequence[@]})." | fmt -w $((min(COLUMNS, 80))) +}