diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-20 00:43:35 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-20 01:21:09 +1200 |
commit | 1ce0e2ad424bf38768094488774eff23b3871ccc (patch) | |
tree | b9d407b2fb7729456ce554d4d610a194447ad737 /sh/profile.d/fortune.sh | |
parent | Use terser shell for executable installs (diff) | |
download | dotfiles-1ce0e2ad424bf38768094488774eff23b3871ccc.tar.gz dotfiles-1ce0e2ad424bf38768094488774eff23b3871ccc.zip |
Port all bash_profile.d scripts to POSIX sh
Also require flag files in ~/.welcome for displaying or not displaying
login stuff
Diffstat (limited to 'sh/profile.d/fortune.sh')
-rw-r--r-- | sh/profile.d/fortune.sh | 24 |
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' +) |