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