a71f8c8
__vi_internal_vim_alias()
a71f8c8
(
76de443
  # run vim if installed
76de443
  test -f /usr/bin/vim && exec /usr/bin/vim "$@"
a71f8c8
76de443
  # run vi otherwise
76de443
  test -f /usr/bin/vi && exec /usr/bin/vi "$@"
76de443
)
76de443
76de443
__view_internal_vim_alias()
76de443
(
76de443
  # run vim -R instead of view if vim installed
76de443
  test -f /usr/bin/vim && exec /usr/bin/vim -R "$@"
a71f8c8
76de443
  # run view otherwise
76de443
  test -f /usr/bin/view && exec /usr/bin/view "$@"
a71f8c8
)
a71f8c8
a71f8c8
82a60bf
if [ -n "${BASH_VERSION-}" -o -n "${KSH_VERSION-}" -o -n "${ZSH_VERSION-}" ]; then
76de443
  # This will avoid user defined aliases
4e95433
  case "$(command -v vim)-$(command -v vi)" in
76de443
    "/usr/bin/vim-/usr/bin/vi" | "-/usr/bin/vi")
17062c8
        # apply only when founded vim and vi are in expected dirs from distro
76de443
        # we need to call a shell function to avoid shell restarts when vi/vim
76de443
        # is being installed/uninstalled
76de443
        alias vi=__vi_internal_vim_alias
76de443
        alias view=__view_internal_vim_alias
a71f8c8
        alias vim=__vi_internal_vim_alias
17062c8
        ;;
17062c8
  esac
82a60bf
fi