Move vim option select to execute logic at alias def time

Using the function would cause problems when trying to perform a `sudo
vim`. The sudo command would run in a root shell which does not have my
shells functions (but does have it's aliases) so then any attempt to
sudo vim would fail with "vim_option_select: command not found"
This commit is contained in:
Andrew R. M 2025-04-05 16:37:09 -04:00 committed by Andrew R. M.
parent 0ce1d88173
commit 6935843cee
2 changed files with 8 additions and 10 deletions

View File

@ -5,6 +5,14 @@
# Allow alias expansion for commands executed with sudo # Allow alias expansion for commands executed with sudo
alias sudo="sudo " alias sudo="sudo "
#{- VIM OPTION SELECT -}#
if which nvim &> /dev/null; then
export PREFERRED_VIM=nvim
else
export PREFERRED_VIM=vim
fi
alias vim="$PREFERRED_VIM "
#{- GNU COREUTILS -}# #{- GNU COREUTILS -}#
# Sort directories first and colorize output # Sort directories first and colorize output

View File

@ -21,13 +21,3 @@ cat_with_newline()
cat "$@" && echo cat "$@" && echo
} }
alias cat="cat_with_newline" alias cat="cat_with_newline"
vim_option_select()
{
if which nvim &> /dev/null; then
nvim "$@"
else
vim "$@"
fi
}
alias vim="vim_option_select "