2020-12-15 14:42:09 +00:00
|
|
|
__vi_internal_vim_alias()
|
|
|
|
(
|
|
|
|
# if user installs vim-enanced and alias is already set
|
|
|
|
test -f /usr/bin/vim && exec vim "$@"
|
|
|
|
|
|
|
|
# if user hates the "No vim found .." interrupting message
|
|
|
|
test -f "$HOME"/.i-know-vim-is-vi && exec vi "$@"
|
|
|
|
|
|
|
|
if [ -n "${ZSH_VERSION-}" ]; then
|
|
|
|
read -t 10 -s -k 1 '?No vim found, using vi, press ENTER to continue...' && echo ''
|
|
|
|
else
|
|
|
|
read -rep $'No vim found, using vi, press ENTER to continue...\n' -n1 -t 10 -s
|
|
|
|
fi
|
|
|
|
exec vi "$@"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2016-05-24 11:08:15 +00:00
|
|
|
if [ -n "${BASH_VERSION-}" -o -n "${KSH_VERSION-}" -o -n "${ZSH_VERSION-}" ]; then
|
2020-10-15 11:45:53 +00:00
|
|
|
# This will avoid user defined aliases and possibly stuff defined earlier in the PATH.
|
2020-10-19 07:48:46 +00:00
|
|
|
case "$(command -v vim)-$(command -v vi)" in
|
2020-10-15 11:45:53 +00:00
|
|
|
/usr/bin/vim-/usr/bin/vi)
|
|
|
|
# apply only when founded vim and vi are in expected dirs from distro
|
|
|
|
alias vi=vim
|
|
|
|
alias view="vim -R"
|
|
|
|
;;
|
|
|
|
-/usr/bin/vi)
|
|
|
|
# apply only if founded vi is in expected dir from distro
|
2020-12-15 14:42:09 +00:00
|
|
|
alias vim=__vi_internal_vim_alias
|
2020-10-15 11:45:53 +00:00
|
|
|
;;
|
|
|
|
esac
|
2016-05-24 11:08:15 +00:00
|
|
|
fi
|