aboutsummaryrefslogtreecommitdiff
path: root/sh/profile.d/verse.sh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2015-06-10 09:13:26 +1200
committerTom Ryder <tom@sanctum.geek.nz>2015-06-10 09:13:26 +1200
commit38acf5a04ad185e04a0b8b68511163e8587da5c2 (patch)
tree11cca68ef987e9de30acf822a3476b51479375ed /sh/profile.d/verse.sh
parentAllow PROMPT_PREFIX and PROMPT_SUFFIX (diff)
downloaddotfiles-38acf5a04ad185e04a0b8b68511163e8587da5c2.tar.gz
dotfiles-38acf5a04ad185e04a0b8b68511163e8587da5c2.zip
Print verse(1) output on login but only once a day
Diffstat (limited to 'sh/profile.d/verse.sh')
-rw-r--r--sh/profile.d/verse.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/sh/profile.d/verse.sh b/sh/profile.d/verse.sh
new file mode 100644
index 00000000..c4fec152
--- /dev/null
+++ b/sh/profile.d/verse.sh
@@ -0,0 +1,15 @@
+# Run verse(1) if it's installed and we haven't seen it already today (the
+# verses are selected by date); run in a subshell to keep vars out of global
+# namespace
+if command -v verse >/dev/null 2>&1 ; then (
+ date=$(date +%Y-%m-%d)
+ versefile=${VERSEFILE:-$HOME/.verse}
+ if [ -e "$HOME"/.verse ] ; then
+ read -r lastversedate < "$versefile"
+ fi
+ if [ "$date" \> "$lastversedate" ] ; then
+ printf '\n%s\n\n' "$(verse)"
+ printf '%s\n' "$date" > "$versefile"
+ fi
+) ; fi
+