env: even more intelligently set EDITOR
This commit is contained in:
parent
123e9217a5
commit
4c1e256d63
1 changed files with 8 additions and 1 deletions
|
@ -55,13 +55,20 @@ if [ -z "$PROFILE_LOADED" ] && [ -f ~/.profile ]; then
|
|||
fi
|
||||
|
||||
# Intelligently set $EDITOR
|
||||
if [ "${EDITOR:-}" = "" ] || [ "${EDITOR##*/}" = "nano" ]; then
|
||||
if [ "${EDITOR:-}" = "" ] ||
|
||||
[ "${EDITOR##*/}" = "nano" ] ||
|
||||
! command -v "$EDITOR" > /dev/null
|
||||
then
|
||||
if command -v nvim > /dev/null;then
|
||||
export EDITOR=nvim
|
||||
elif command -v vim > /dev/null;then
|
||||
export EDITOR=vim
|
||||
elif command -v vi > /dev/null;then
|
||||
export EDITOR=vi
|
||||
elif command -v nano > /dev/null; then
|
||||
export EDITOR=nano
|
||||
else
|
||||
echo "Error: couldn't find a valid candidate for \$EDITOR" >&2
|
||||
fi
|
||||
fi
|
||||
export SYSTEMD_EDITOR="$EDITOR"
|
||||
|
|
Loading…
Add table
Reference in a new issue