aboutsummaryrefslogtreecommitdiff
path: root/sh/profile.d/fortune.sh
blob: a58941084024e90f59b80c53574dc227c389808c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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'
)