diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | README.markdown | 9 | ||||
-rw-r--r-- | bash/bash_profile | 6 | ||||
-rw-r--r-- | bash/bash_profile.d/fortune.bash | 19 | ||||
-rw-r--r-- | bash/bash_profile.d/remind.bash | 22 | ||||
-rw-r--r-- | bash/bash_profile.d/verse.bash | 24 | ||||
-rwxr-xr-x | check/bash | 2 | ||||
-rw-r--r-- | sh/profile | 1 | ||||
-rw-r--r-- | sh/profile.d/fortune.sh | 24 | ||||
-rw-r--r-- | sh/profile.d/remind.sh | 19 | ||||
-rw-r--r-- | sh/profile.d/verse.sh | 28 |
11 files changed, 78 insertions, 80 deletions
@@ -141,12 +141,10 @@ install-abook : install-bash : check-bash install-sh install -m 0755 -d -- \ "$(HOME)"/.config \ - "$(HOME)"/.bashrc.d \ - "$(HOME)"/.bash_profile.d + "$(HOME)"/.bashrc.d install -pm 0644 -- bash/bashrc "$(HOME)"/.bashrc install -pm 0644 -- bash/bashrc.d/* "$(HOME)"/.bashrc.d install -pm 0644 -- bash/bash_profile "$(HOME)"/.bash_profile - install -pm 0644 -- bash/bash_profile.d/* "$(HOME)"/.bash_profile.d install -pm 0644 -- bash/bash_logout "$(HOME)"/.bash_logout install-bash-completion : install-bash diff --git a/README.markdown b/README.markdown index 47197122..d6ace0d3 100644 --- a/README.markdown +++ b/README.markdown @@ -98,11 +98,10 @@ they should work in most `sh(1)` implementations. Individual scripts called by management. All of these boil down to exporting variables appropriate to the system and the software it has available. -My `.bash_profile` calls `.profile` and then runs subscripts in -`.bash_profile.d`. It then runs `.bashrc`, which only applies for interactive -shells; subscripts for that in turn are loaded from `.bashrc.d`. The contents -of the two directories changes depending on the host, so only specific scripts -in it are versioned. +My `.bash_profile` calls `.profile`, and then `.bashrc`, which only applies for +interactive shells. Subscripts for `.bashrc` are loaded from `.bashrc.d`. The +contents of the two directories changes depending on the host, so only specific +scripts in it are versioned. My interactive and scripting shell of choice is Bash; as a GNU/Linux admin who ends up installing Bash on \*BSD machines anyway, I very rarely have to write diff --git a/bash/bash_profile b/bash/bash_profile index db1d9bc8..69350102 100644 --- a/bash/bash_profile +++ b/bash/bash_profile @@ -13,12 +13,6 @@ elif ((BASH_VERSINFO[0] == 2)) && return fi -# Load any supplementary scripts -for sh in "$HOME"/.bash_profile.d/*.bash ; do - [[ -e $sh ]] && source "$sh" -done -unset -v sh - # If ~/.bashrc exists, source that too; the test for interactivity is in there if [[ -f $HOME/.bashrc ]] ; then source "$HOME"/.bashrc diff --git a/bash/bash_profile.d/fortune.bash b/bash/bash_profile.d/fortune.bash deleted file mode 100644 index cc16ff05..00000000 --- a/bash/bash_profile.d/fortune.bash +++ /dev/null @@ -1,19 +0,0 @@ -# Only if shell is interactive -if [[ $- != *i* ]] ; then - return -fi - -# Only if fortune(6) available -if ! hash fortune 2>/dev/null ; then - return -fi - -# 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 -s "$FORTUNE_PATH" - printf '\n' -) diff --git a/bash/bash_profile.d/remind.bash b/bash/bash_profile.d/remind.bash deleted file mode 100644 index a8f14599..00000000 --- a/bash/bash_profile.d/remind.bash +++ /dev/null @@ -1,22 +0,0 @@ -# Only if shell is interactive -if [[ $- != *i* ]] ; then - return -fi - -# Only if rem(1) available -if ! hash rem 2>/dev/null ; then - return -fi - -# Only if reminders file exists -if [[ ! -e ${DOTREMINDERS:-$HOME/.reminders} ]] ; then - return -fi - -# Print from subshell to keep namespace clean -( - while IFS= read -r reminder ; do - printf '* %s\n' "$reminder" - done < <(rem -hq) - printf '\n' -) diff --git a/bash/bash_profile.d/verse.bash b/bash/bash_profile.d/verse.bash deleted file mode 100644 index 69c48021..00000000 --- a/bash/bash_profile.d/verse.bash +++ /dev/null @@ -1,24 +0,0 @@ -# Only if shell is interactive -if [[ $- != *i* ]] ; then - return -fi - -# Only if verse(1) available -if ! hash verse 2>/dev/null ; then - return -fi - -# 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 -( - date=$(date +%Y-%m-%d) - versefile=${VERSEFILE:-$HOME/.verse} - if [[ -e $versefile ]] ; then - IFS= read -r lastversedate < "$versefile" - fi - if [[ $date > $lastversedate ]] ; then - verse - printf '\n' - printf '%s\n' "$date" > "$versefile" - fi -) @@ -1,5 +1,5 @@ #!/bin/sh -for bash in bash/* bash/bashrc.d/* bash/bash_profile.d/* ; do +for bash in bash/* bash/bashrc.d/* ; do [ -f "$bash" ] || continue bash -n "$bash" || exit done @@ -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 +) |