aboutsummaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
Diffstat (limited to 'sh')
-rw-r--r--sh/profile1
-rw-r--r--sh/profile.d/fortune.sh24
-rw-r--r--sh/profile.d/remind.sh19
-rw-r--r--sh/profile.d/verse.sh28
4 files changed, 72 insertions, 0 deletions
diff --git a/sh/profile b/sh/profile
index 7fea250b..7266d64e 100644
--- a/sh/profile
+++ b/sh/profile
@@ -20,6 +20,7 @@ logout_trap() {
fi
}
for sig in EXIT HUP INT TERM ; do
+ # shellcheck disable=SC2064
trap "logout_trap $sig" "$sig"
done
unset -v sig
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'
+)
diff --git a/sh/profile.d/remind.sh b/sh/profile.d/remind.sh
new file mode 100644
index 00000000..3ef0f353
--- /dev/null
+++ b/sh/profile.d/remind.sh
@@ -0,0 +1,19 @@
+# Only if shell is interactive
+case $- in
+ *i*) ;;
+ *) return ;;
+esac
+
+# Only if not in a tmux window
+[ -z "$TMUX" ] || return
+
+# Only if ~/.welcome/remind exists and ~/.hushlogin doesn't
+[ -e "$HOME"/.welcome/remind ] || return
+! [ -e "$HOME"/.hushlogin ] || return
+
+# Only if rem(1) available
+command -v rem >/dev/null 2>&1 || return
+
+# Print reminders with asterisks
+rem -hq | sed 's/^/* /'
+printf '\n'
diff --git a/sh/profile.d/verse.sh b/sh/profile.d/verse.sh
new file mode 100644
index 00000000..781d68bc
--- /dev/null
+++ b/sh/profile.d/verse.sh
@@ -0,0 +1,28 @@
+# Only if shell is interactive
+case $- in
+ *i*) ;;
+ *) return ;;
+esac
+
+# Only if not in a tmux window on this machine
+[ -z "$TMUX" ] || return
+
+# Only if ~/.welcome/verse exists and ~/.hushlogin doesn't
+[ -e "$HOME"/.welcome/verse ] || return
+! [ -e "$HOME"/.hushlogin ] || return
+
+# Only if verse(1) available
+command -v verse >/dev/null 2>&1 || return
+
+# Run verse(1) if we haven't seen it already today (the verses are selected by
+# date); run in a subshell to keep vars out of global namespace
+(
+ now=$(date +%Y-%m-%d)
+ if [ -f "$HOME"/.verse ] ; then
+ last=$(cat -- "$HOME"/.verse)
+ fi
+ [ "$now" \> "$last" ] || exit
+ verse
+ printf '\n'
+ printf '%s\n' "$now" > "$HOME"/.verse
+)