aboutsummaryrefslogtreecommitdiff
path: root/sh/profile.d/fortune.sh
diff options
context:
space:
mode:
Diffstat (limited to 'sh/profile.d/fortune.sh')
-rw-r--r--sh/profile.d/fortune.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/sh/profile.d/fortune.sh b/sh/profile.d/fortune.sh
new file mode 100644
index 00000000..a5894108
--- /dev/null
+++ b/sh/profile.d/fortune.sh
@@ -0,0 +1,24 @@
+# Only if shell is interactive
+case $- in
+ *i*) ;;
+ *) return ;;
+esac
+
+# Only if not in a tmux window
+[ -z "$TMUX" ] || return
+
+# Only if ~/.welcome/fortune exists and ~/.hushlogin doesn't
+[ -e "$HOME"/.welcome/fortune ] || return
+! [ -e "$HOME"/.hushlogin ] || return
+
+# Only if fortune(6) available
+command -v fortune >/dev/null 2>&1 || return
+
+# Print from subshell to keep namespace clean
+(
+ if [ -d "$HOME"/.local/share/games/fortunes ] ; then
+ : "${FORTUNE_PATH:="$HOME"/.local/share/games/fortunes}"
+ fi
+ fortune -s "$FORTUNE_PATH"
+ printf '\n'
+)