2020-12-16 14:22:16 +00:00
|
|
|
__vi_internal_vim_alias()
|
|
|
|
(
|
|
|
|
# run vim if installed
|
|
|
|
test -f /usr/bin/vim && exec /usr/bin/vim "$@"
|
|
|
|
|
|
|
|
# run vi otherwise
|
|
|
|
test -f /usr/bin/vi && exec /usr/bin/vi "$@"
|
|
|
|
)
|
|
|
|
|
|
|
|
__view_internal_vim_alias()
|
|
|
|
(
|
|
|
|
# run vim -R instead of view if vim installed
|
|
|
|
test -f /usr/bin/vim && exec /usr/bin/vim -R "$@"
|
|
|
|
|
|
|
|
# run view otherwise
|
|
|
|
test -f /usr/bin/view && exec /usr/bin/view "$@"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-10-15 20:25:22 +00:00
|
|
|
if [ -n "${BASH_VERSION-}" -o -n "${KSH_VERSION-}" -o -n "${ZSH_VERSION-}" ]; then
|
2020-12-16 14:22:16 +00:00
|
|
|
# This will avoid user defined aliases
|
2020-10-27 23:05:29 +00:00
|
|
|
case "$(command -v vim)-$(command -v vi)" in
|
2020-12-16 14:22:16 +00:00
|
|
|
"/usr/bin/vim-/usr/bin/vi" | "-/usr/bin/vi")
|
2020-10-15 20:25:22 +00:00
|
|
|
# apply only when founded vim and vi are in expected dirs from distro
|
2020-12-16 14:22:16 +00:00
|
|
|
# we need to call a shell function to avoid shell restarts when vi/vim
|
|
|
|
# is being installed/uninstalled
|
|
|
|
alias vi=__vi_internal_vim_alias
|
|
|
|
alias view=__view_internal_vim_alias
|
|
|
|
alias vim=__vi_internal_vim_alias
|
2020-10-15 20:25:22 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|