aboutsummaryrefslogtreecommitdiff
path: root/sh/profile.d/verse.sh
diff options
context:
space:
mode:
Diffstat (limited to 'sh/profile.d/verse.sh')
-rw-r--r--sh/profile.d/verse.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/sh/profile.d/verse.sh b/sh/profile.d/verse.sh
new file mode 100644
index 00000000..781d68bc
--- /dev/null
+++ b/sh/profile.d/verse.sh
@@ -0,0 +1,28 @@
+# Only if shell is interactive
+case $- in
+ *i*) ;;
+ *) return ;;
+esac
+
+# Only if not in a tmux window on this machine
+[ -z "$TMUX" ] || return
+
+# Only if ~/.welcome/verse exists and ~/.hushlogin doesn't
+[ -e "$HOME"/.welcome/verse ] || return
+! [ -e "$HOME"/.hushlogin ] || return
+
+# Only if verse(1) available
+command -v verse >/dev/null 2>&1 || return
+
+# Run verse(1) if we haven't seen it already today (the verses are selected by
+# date); run in a subshell to keep vars out of global namespace
+(
+ now=$(date +%Y-%m-%d)
+ if [ -f "$HOME"/.verse ] ; then
+ last=$(cat -- "$HOME"/.verse)
+ fi
+ [ "$now" \> "$last" ] || exit
+ verse
+ printf '\n'
+ printf '%s\n' "$now" > "$HOME"/.verse
+)