diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2015-12-15 16:01:07 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2015-12-15 16:01:07 +1300 |
commit | 7b1b82761bcab157de124def3944dd95b19268b6 (patch) | |
tree | 1a181ac352e5963922c3a777322d9916d976950f /bash/bash_profile.d/fortune.bash | |
parent | Remove unneeded args spec (diff) | |
download | dotfiles-7b1b82761bcab157de124def3944dd95b19268b6.tar.gz dotfiles-7b1b82761bcab157de124def3944dd95b19268b6.zip |
Flatten bash_profile.d subscripts a bit
Diffstat (limited to 'bash/bash_profile.d/fortune.bash')
-rw-r--r-- | bash/bash_profile.d/fortune.bash | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/bash/bash_profile.d/fortune.bash b/bash/bash_profile.d/fortune.bash index f3ef2be9..9879716a 100644 --- a/bash/bash_profile.d/fortune.bash +++ b/bash/bash_profile.d/fortune.bash @@ -1,10 +1,16 @@ -# If interactive shell and fortune(6) installed, print a short fortune -if [[ $- == *i* ]] && hash fortune 2>/dev/null ; then ( +# Only if shell is interactive +[[ $- == *i* ]] || return + +# Only if fortune(6) available +hash fortune 2>/dev/null || return + +# Print from subshell to keep namespace clean +( if [[ -d $HOME/.local/share/games/fortunes ]] ; then FORTUNE_PATH=${FORTUNE_PATH:-$HOME/.local/share/games/fortunes} fi printf '\n' fortune -sn "${FORTUNE_MAXSIZE:-768}" "$FORTUNE_PATH" printf '\n' -) ; fi +) |