aboutsummaryrefslogtreecommitdiff
path: root/sh/profile.d
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-25 23:26:58 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-25 23:26:58 +1200
commit84871deb0ac09dd34872a8af31385c6997a387f6 (patch)
tree3845c5ea2e8a9c65178a9deeca3467dc49bf0778 /sh/profile.d
parentRemove default PS1 for sh (diff)
downloaddotfiles-84871deb0ac09dd34872a8af31385c6997a387f6.tar.gz
dotfiles-84871deb0ac09dd34872a8af31385c6997a387f6.zip
Combine welcome messages into one script
Diffstat (limited to 'sh/profile.d')
-rw-r--r--sh/profile.d/fortune.sh23
-rw-r--r--sh/profile.d/remind.sh19
-rw-r--r--sh/profile.d/verse.sh27
-rw-r--r--sh/profile.d/welcome.sh54
4 files changed, 54 insertions, 69 deletions
diff --git a/sh/profile.d/fortune.sh b/sh/profile.d/fortune.sh
deleted file mode 100644
index d7f1d202..00000000
--- a/sh/profile.d/fortune.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-# 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
-(
- [ -d "$HOME"/.local/share/games/fortunes ] &&
- : "${FORTUNE_PATH:="$HOME"/.local/share/games/fortunes}"
- fortune -s "$FORTUNE_PATH"
- printf '\n'
-)
diff --git a/sh/profile.d/remind.sh b/sh/profile.d/remind.sh
deleted file mode 100644
index 3ef0f353..00000000
--- a/sh/profile.d/remind.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-# 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
deleted file mode 100644
index 303a1b05..00000000
--- a/sh/profile.d/verse.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-# 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)
- last=0
- [ -f "$HOME"/.verse ] && last=$(cat -- "$HOME"/.verse)
- [ "$now" -gt "$last" ] || exit
- verse
- printf '\n'
- printf '%s\n' "$now" > "$HOME"/.verse
-)
diff --git a/sh/profile.d/welcome.sh b/sh/profile.d/welcome.sh
new file mode 100644
index 00000000..26bf678f
--- /dev/null
+++ b/sh/profile.d/welcome.sh
@@ -0,0 +1,54 @@
+# Only if shell is interactive
+case $- in
+ *i*) ;;
+ *) return ;;
+esac
+
+# Only if not in a tmux window
+[ -z "$TMUX" ] || return
+
+# Not if ~/.hushlogin exists
+[ -e "$HOME"/.hushlogin ] && return
+
+(
+ # Only if ~/.welcome/fortune exists
+ [ -e "$HOME"/.welcome/fortune ] || exit
+
+ # Only if fortune(6) available
+ command -v fortune >/dev/null 2>&1 || exit
+
+ # Show a fortune
+ [ -d "$HOME"/.local/share/games/fortunes ] &&
+ : "${FORTUNE_PATH:="$HOME"/.local/share/games/fortunes}"
+ fortune -s "$FORTUNE_PATH"
+ printf '\n'
+)
+(
+ # Only if ~/.welcome/remind exists
+ [ -e "$HOME"/.welcome/remind ] || exit
+
+ # Only if rem(1) available
+ command -v rem >/dev/null 2>&1 || exit
+
+ # Print reminders with asterisks
+ rem -hq | sed 's/^/* /'
+ printf '\n'
+)
+(
+ # Only if ~/.welcome/remind verse
+ [ -e "$HOME"/.welcome/verse ] || exit
+
+ # Only if verse(1) available
+ command -v verse >/dev/null 2>&1 || exit
+
+ # 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)
+ last=0
+ [ -f "$HOME"/.verse ] &&
+ last=$(cat -- "$HOME"/.verse)
+ [ "$now" -gt "$last" ] || exit
+ verse
+ printf '\n'
+ printf '%s\n' "$now" > "$HOME"/.verse
+)