From 9789ca848df6f49236cbb4d2bb9879b9a07b1eac Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 28 Jul 2022 14:52:07 +1200 Subject: Stop abusing MANPATH for plenv, pyenv, rbenv It's too error-prone. Better to use the relevant documentation frontends so that it's clearer which version I'm reading. --- plenv/profile.d/plenv.sh | 4 +--- pyenv/profile.d/pyenv.sh | 4 +--- rbenv/profile.d/rbenv.sh | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/plenv/profile.d/plenv.sh b/plenv/profile.d/plenv.sh index b2b491e1..52750e9c 100644 --- a/plenv/profile.d/plenv.sh +++ b/plenv/profile.d/plenv.sh @@ -1,5 +1,3 @@ -# Add plenv to PATH and MANPATH if it appears to be in use +# Add plenv to PATH if its home directory exists [ -d "$HOME"/.plenv ] || return PATH=$HOME/.plenv/shims:$HOME/.plenv/bin:$PATH -MANPATH=$HOME/.plenv/versions/$(perl -e 'print substr($^V,1)')/man:$MANPATH -export MANPATH diff --git a/pyenv/profile.d/pyenv.sh b/pyenv/profile.d/pyenv.sh index cddcdd9e..4e0e40e1 100644 --- a/pyenv/profile.d/pyenv.sh +++ b/pyenv/profile.d/pyenv.sh @@ -1,5 +1,3 @@ -# Define env vars for pyenv if it appears to be in use +# Add pyenv to PATH if its home directory exists [ -d "$HOME"/.pyenv ] || return PATH=$HOME/.pyenv/shims:$HOME/.pyenv/bin:$PATH -MANPATH=$HOME/.pyenv/versions/$(python3 -V|cut -d' ' -f2)/share/man:$MANPATH -export MANPATH diff --git a/rbenv/profile.d/rbenv.sh b/rbenv/profile.d/rbenv.sh index 52787b4d..e1e3d85f 100644 --- a/rbenv/profile.d/rbenv.sh +++ b/rbenv/profile.d/rbenv.sh @@ -1,5 +1,3 @@ -# Add rbenv to PATH and MANPATH if it appears to be in use +# Add rbenv to PATH if its home directory exists [ -d "$HOME"/.rbenv ] || return PATH=$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH -MANPATH=$HOME/.rbenv/versions/$(ruby -e 'print "#{ RUBY_VERSION }"')/man:$MANPATH -export MANPATH -- cgit v1.2.3 From 94ca1e53168a6691b2a9d0990290e31e30f97396 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 29 Jul 2022 01:31:21 +1200 Subject: Remove disused $OS env var and switch --- sh/profile.d/os.sh | 3 --- sh/shrc.d/ls.sh | 10 ---------- 2 files changed, 13 deletions(-) delete mode 100644 sh/profile.d/os.sh diff --git a/sh/profile.d/os.sh b/sh/profile.d/os.sh deleted file mode 100644 index f9d5a79b..00000000 --- a/sh/profile.d/os.sh +++ /dev/null @@ -1,3 +0,0 @@ -# Store the operating system in an environment variable -OS=$(uname) -export OS diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh index c6558fc3..6fbfbf61 100644 --- a/sh/shrc.d/ls.sh +++ b/sh/shrc.d/ls.sh @@ -41,16 +41,6 @@ ls() { set -- --time-style='+%Y-%m-%d %H:%M:%S' "$@" fi - # If the operating system is FreeBSD, there are some specific options we - # can add that might mean different things to e.g. GNU ls(1) - case $OS in - FreeBSD) - # -D: Timestamp format - # -G: Use color - set -- -D '%Y-%m-%d %H:%M:%S' -G "$@" - ;; - esac - # Run ls(1) with the concluded arguments command ls "$@" } -- cgit v1.2.3 From 5bad95b47ef6b594a307fdd454641e99bec5947e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 29 Jul 2022 01:31:32 +1200 Subject: Massively cut down profile scripts Let's simplify all this a bit. --- cabal/profile.d/cabal.sh | 3 +-- cargo/profile.d/cabal.sh | 3 +-- plenv/profile.d/plenv.sh | 3 +-- pyenv/profile.d/pyenv.sh | 3 +-- rbenv/profile.d/rbenv.sh | 3 +-- sh/profile | 31 ++++++++++++++++++++------- sh/profile.d/browser.sh | 10 --------- sh/profile.d/downloads.sh | 33 ----------------------------- sh/profile.d/editor.sh | 25 ---------------------- sh/profile.d/games.sh | 3 --- sh/profile.d/lang.sh | 4 ---- sh/profile.d/pager.sh | 7 ------- sh/profile.d/timezone.sh | 3 --- sh/profile.d/visual.sh | 14 ------------- sh/profile.d/welcome.sh | 53 ----------------------------------------------- 15 files changed, 28 insertions(+), 170 deletions(-) delete mode 100644 sh/profile.d/browser.sh delete mode 100644 sh/profile.d/downloads.sh delete mode 100644 sh/profile.d/editor.sh delete mode 100644 sh/profile.d/games.sh delete mode 100644 sh/profile.d/lang.sh delete mode 100644 sh/profile.d/pager.sh delete mode 100644 sh/profile.d/timezone.sh delete mode 100644 sh/profile.d/visual.sh delete mode 100644 sh/profile.d/welcome.sh diff --git a/cabal/profile.d/cabal.sh b/cabal/profile.d/cabal.sh index b5730916..638f8d04 100644 --- a/cabal/profile.d/cabal.sh +++ b/cabal/profile.d/cabal.sh @@ -1,3 +1,2 @@ -# Include user-built Haskell programs if the dir exists -[ -d "$HOME"/.cabal/bin ] || return +# Include user-built Haskell programs PATH=$HOME/.cabal/bin:$PATH diff --git a/cargo/profile.d/cabal.sh b/cargo/profile.d/cabal.sh index b5730916..638f8d04 100644 --- a/cargo/profile.d/cabal.sh +++ b/cargo/profile.d/cabal.sh @@ -1,3 +1,2 @@ -# Include user-built Haskell programs if the dir exists -[ -d "$HOME"/.cabal/bin ] || return +# Include user-built Haskell programs PATH=$HOME/.cabal/bin:$PATH diff --git a/plenv/profile.d/plenv.sh b/plenv/profile.d/plenv.sh index 52750e9c..36d6289b 100644 --- a/plenv/profile.d/plenv.sh +++ b/plenv/profile.d/plenv.sh @@ -1,3 +1,2 @@ -# Add plenv to PATH if its home directory exists -[ -d "$HOME"/.plenv ] || return +# Add plenv shims and bindir to PATH PATH=$HOME/.plenv/shims:$HOME/.plenv/bin:$PATH diff --git a/pyenv/profile.d/pyenv.sh b/pyenv/profile.d/pyenv.sh index 4e0e40e1..3ad73c68 100644 --- a/pyenv/profile.d/pyenv.sh +++ b/pyenv/profile.d/pyenv.sh @@ -1,3 +1,2 @@ -# Add pyenv to PATH if its home directory exists -[ -d "$HOME"/.pyenv ] || return +# Add pyenv shims and bindir to PATH PATH=$HOME/.pyenv/shims:$HOME/.pyenv/bin:$PATH diff --git a/rbenv/profile.d/rbenv.sh b/rbenv/profile.d/rbenv.sh index e1e3d85f..522ff247 100644 --- a/rbenv/profile.d/rbenv.sh +++ b/rbenv/profile.d/rbenv.sh @@ -1,3 +1,2 @@ -# Add rbenv to PATH if its home directory exists -[ -d "$HOME"/.rbenv ] || return +# Add rbenv shims and bindir to PATH PATH=$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH diff --git a/sh/profile b/sh/profile index 30247e24..0926a250 100644 --- a/sh/profile +++ b/sh/profile @@ -1,15 +1,30 @@ -# Add ~/.local/bin to PATH -PATH=$HOME/.local/bin:$PATH +# Use lynx as our terminal browser +export BROWSER=lynx -# Load all supplementary scripts in ~/.profile.d +# Use ed as our line editor and vi as our visual editor +export EDITOR=ed +export VISUAL=vi + +# Set the POSIX interactive startup file to ~/.shinit +export ENV=$HOME/.shinit + +# Always use bytewise sorting +export LC_COLLATE=C + +# Use less as my pager +export PAGER=less + +# Assume I'm at home unless something overrides it +export TZ=Pacific/Auckland + +# Source all scripts in ~/.profile.d; many of them will be modifying $PATH, so +# we'll get that sorted out first for sh in "$HOME"/.profile.d/*.sh ; do [ -e "$sh" ] || continue . "$sh" done unset -v sh -# If ~/.shinit exists, set ENV to that -if [ -f "$HOME"/.shinit ] ; then - ENV=$HOME/.shinit - export ENV -fi +# Add ~/.local/bin and ~/.local/games to the very front of PATH, so that it +# overrides everything else +PATH=$HOME/.local/bin:$HOME/.local/games:$PATH diff --git a/sh/profile.d/browser.sh b/sh/profile.d/browser.sh deleted file mode 100644 index ce18e127..00000000 --- a/sh/profile.d/browser.sh +++ /dev/null @@ -1,10 +0,0 @@ -# Set command-line browser to Debian's alternatives name www-browser, or -# failing that, just to `lynx`; ~/.xsession will change this to something -# graphical instead if invoked. -# -if command -v www-browser >/dev/null 2>&1 ; then - BROWSER=www-browser -else - BROWSER=lynx -fi -export BROWSER diff --git a/sh/profile.d/downloads.sh b/sh/profile.d/downloads.sh deleted file mode 100644 index 1a89bc3f..00000000 --- a/sh/profile.d/downloads.sh +++ /dev/null @@ -1,33 +0,0 @@ -# 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 - -# Not if ~/.downloads doesn't -[ -f "$HOME"/.downloads ] || return - -# Count files in each directory, report if greater than zero -( - lc=0 - while IFS= read -r dir ; do - case $dir in - '#'*) continue ;; - esac - [ -d "$dir" ] || continue - set -- "$dir"/* - [ -e "$1" ] || shift - [ "$#" -gt 0 ] || continue - printf 'You have %u unsorted files in %s.\n' "$#" "$dir" - lc=$((lc+1)) - done < "$HOME"/.downloads - if [ "$lc" -gt 0 ] ; then - printf '\n' - fi -) diff --git a/sh/profile.d/editor.sh b/sh/profile.d/editor.sh deleted file mode 100644 index 37146fb9..00000000 --- a/sh/profile.d/editor.sh +++ /dev/null @@ -1,25 +0,0 @@ -# Ideally, we'd use plain old ed(1), but many Linux distributions don't install -# it by default -if command -v ed >/dev/null 2>&1 ; then - EDITOR='ed' - -# Failing that, if the system's implementation of ex(1) looks like Vim and we -# have exm(1df) in our $PATH, use the latter to work around Vim's ex mode -# screen-clearing -elif ( - command -v ex >/dev/null 2>&1 || exit 1 - command -v exm >/dev/null 2>&1 || exit 1 - ver=$(ex --version 2>/dev/null | awk '{print $1;exit}') - case $ver in - (VIM) exit 0 ;; - (*) exit 1 ;; - esac -) >/dev/null 2>&1 ; then - EDITOR='exm' - -# Otherwise, we can just call ex(1) directly -else - EDITOR='ex' -fi - -export EDITOR diff --git a/sh/profile.d/games.sh b/sh/profile.d/games.sh deleted file mode 100644 index 956d1de1..00000000 --- a/sh/profile.d/games.sh +++ /dev/null @@ -1,3 +0,0 @@ -# Add ~/.local/games to PATH if it exists -[ -d "$HOME"/.local/games ] || return -PATH=$PATH:$HOME/.local/games diff --git a/sh/profile.d/lang.sh b/sh/profile.d/lang.sh deleted file mode 100644 index 21f67d5b..00000000 --- a/sh/profile.d/lang.sh +++ /dev/null @@ -1,4 +0,0 @@ -# Always use bytewise sorting if not already set -[ -z "$LC_COLLATE" ] || return -LC_COLLATE=C -export LC_COLLATE diff --git a/sh/profile.d/pager.sh b/sh/profile.d/pager.sh deleted file mode 100644 index f0c4fab4..00000000 --- a/sh/profile.d/pager.sh +++ /dev/null @@ -1,7 +0,0 @@ -# If we don't have less(1), we'll just use whatever pager the application or -# system deems fit -command -v less >/dev/null 2>&1 || return - -# Use less(1) as my PAGER -PAGER=less -export PAGER diff --git a/sh/profile.d/timezone.sh b/sh/profile.d/timezone.sh deleted file mode 100644 index cbd33539..00000000 --- a/sh/profile.d/timezone.sh +++ /dev/null @@ -1,3 +0,0 @@ -# Timezone -TZ=Pacific/Auckland -export TZ diff --git a/sh/profile.d/visual.sh b/sh/profile.d/visual.sh deleted file mode 100644 index eb3c1143..00000000 --- a/sh/profile.d/visual.sh +++ /dev/null @@ -1,14 +0,0 @@ -# For a visual editor, use Vim explicitly if we've got it, but otherwise any vi -# implementation will be fine -if command -v vim >/dev/null 2>&1 ; then - VISUAL='vim' -else - VISUAL='vi' -fi -export VISUAL - -# If systemctl is installed, use $VISUAL as its editor, not $EDITOR -if command -v systemctl >/dev/null 2>&1 ; then - SYSTEMD_EDITOR=$VISUAL - export SYSTEMD_EDITOR -fi diff --git a/sh/profile.d/welcome.sh b/sh/profile.d/welcome.sh deleted file mode 100644 index 19231c2e..00000000 --- a/sh/profile.d/welcome.sh +++ /dev/null @@ -1,53 +0,0 @@ -# Only if shell is interactive -case $- in - *i*) ;; - *) return ;; -esac - -# Only if not in a tmux window -[ -z "$TMUX" ] || return - -# Only if ~/.hushlogin doesn't exist -! [ -e "$HOME"/.hushlogin ] || return - -# Run all of this in a subshell to clear it away afterwards -( - # Temporary helper function - welcome() { - test -e "${XDG_CONFIG_HOME:-"$HOME"/.config}"/welcome/"$1" - } - - # Show a fortune - if welcome fortune ; then - if [ -z "$FORTUNE_PATH" ] ; then - FORTUNE_PATH=${XDG_DATA_HOME:-$HOME}/.local/share/fortune - set -- "$FORTUNE_PATH"/*.dat - if ! [ -e "$1" ] ; then - FORTUNE_PATH= - fi - fi - fortune -s "$FORTUNE_PATH" - printf '\n' - fi - - # Print today's reminders with asterisks - if welcome rem ; then - rem -hq | sed 's/^/* /' - printf '\n' - fi - - # Run verse(1) if we haven't seen it already today - if welcome verse ; then - cache=${XDG_CACHE_HOME:-$HOME/.cache}/welcome - mkdir -p -- "$cache" || return - if [ -f "$cache"/verse ] ; then - read -r last <"$cache"/verse - fi - now=$(date +%Y%m%d) - if [ "$now" -gt "${last:-0}" ] ; then - verse - printf '\n' - printf '%s\n' "$now" >"$cache"/verse - fi - fi -) -- cgit v1.2.3 From 28af95507d5aaf00ef85c78f90a9a957ca88192b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 29 Jul 2022 01:33:57 +1200 Subject: Bump VERSION --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index c4e7f0a0..8b980950 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -tejr dotfiles v12.11.0 -Wed, 27 Jul 2022 01:36:28 +0000 +tejr dotfiles v12.12.0 +Thu, 28 Jul 2022 13:33:57 +0000 -- cgit v1.2.3