diff options
Diffstat (limited to 'sh/profile.d')
-rw-r--r-- | sh/profile.d/editor.sh | 17 | ||||
-rw-r--r-- | sh/profile.d/options.sh | 2 | ||||
-rw-r--r-- | sh/profile.d/visual.sh | 8 |
3 files changed, 16 insertions, 11 deletions
diff --git a/sh/profile.d/editor.sh b/sh/profile.d/editor.sh index 307879fe..debb93b6 100644 --- a/sh/profile.d/editor.sh +++ b/sh/profile.d/editor.sh @@ -3,12 +3,21 @@ if command -v ed >/dev/null 2>&1 ; then EDITOR=ed -# Failing that, if we have both vim(1) and exm(1df) in our $PATH, use the -# latter to work around Vim's ex mode screen-clearing -elif { command -v vim && command -v exm ; } >/dev/null 2>&1 ; then +# 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 'NR==1{print $1;exit}') + case $ver in + (VIM) exit 0 ;; + (*) exit 1 ;; + esac +) >/dev/null 2>&1 ; then EDITOR=exm -# Otherwise, just call ex(1) directly +# Otherwise, we can just call ex(1) directly else EDITOR=ex fi diff --git a/sh/profile.d/options.sh b/sh/profile.d/options.sh index 1a511d75..89b5d245 100644 --- a/sh/profile.d/options.sh +++ b/sh/profile.d/options.sh @@ -5,7 +5,7 @@ options() { # Check or create the directory to cache the options # Shift the program name off; remaining arguments are the options to check - dir=$HOME/.cache/$1 + dir=$HOME/.cache/sh/opt/$1 prog=$1 shift diff --git a/sh/profile.d/visual.sh b/sh/profile.d/visual.sh index d03da255..38ab9893 100644 --- a/sh/profile.d/visual.sh +++ b/sh/profile.d/visual.sh @@ -1,7 +1,3 @@ -# Set visual editor; vim if we've got it, but vi will do fine -if command -v vim >/dev/null 2>&1 ; then - VISUAL=vim -else - VISUAL=vi -fi +# Use first found implementation of vi(1) +VISUAL=vi export VISUAL |