From 30a2230f801a6b4335222811b495d82acb357b52 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Tue, 26 Nov 2024 17:01:56 +0000 Subject: [PATCH] [shell-common] Select an editor (resolves #1) --- shell-common/.config/shell-common/exports.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/shell-common/.config/shell-common/exports.sh b/shell-common/.config/shell-common/exports.sh index babf820..dbc06d6 100644 --- a/shell-common/.config/shell-common/exports.sh +++ b/shell-common/.config/shell-common/exports.sh @@ -7,13 +7,14 @@ export TZ=GB export LANG=en_GB.UTF-8 # Make a sensible editor choice -if [ -x /usr/bin/nano ]; then - export EDITOR=nano - export VISUAL=nano -else - export EDITOR=vi - export VISUAL=vi -fi +editor_preferences=(nano pico vim vi) +for editor in "${editor_preferences[@]}"; do + if [ -x "$(which $editor)" ]; then + export EDITOR=$editor + export VISUAL=$editor + break + fi +done # Go stuff export GOPATH=$HOME/go/