vim/vim.sh
Zdenek Dohnal 17062c8b2d vim.sh, vim.csh - set aliases only for OS default vi and vim
Do not set them for locally built vi/vim or replace existing aliases.
2020-10-15 13:45:53 +02:00

15 lines
610 B
Bash

if [ -n "${BASH_VERSION-}" -o -n "${KSH_VERSION-}" -o -n "${ZSH_VERSION-}" ]; then
# This will avoid user defined aliases and possibly stuff defined earlier in the PATH.
case "$(which vim 2> /dev/null)-$(which vi 2> /dev/null)" in
/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
alias vim="read -rep $'No vim found, using vi, press ENTER to continue\n' -n1 -t 20 -s && vi"
;;
esac
fi