Zdenek Dohnal 640663
# This will avoid user defined aliases and possibly stuff defined earlier in the PATH.
Zdenek Dohnal 640663
# Redirecting is for the case when the binary is missing.
Zdenek Dohnal 4e9543
set vim_cond (command -v vim)
Zdenek Dohnal 4e9543
set vi_cond (command -v vi)
Zdenek Dohnal 640663
Zdenek Dohnal 640663
switch "$vim_cond-$vi_cond"
Zdenek Dohnal 640663
  case /usr/bin/vim-/usr/bin/vi
Zdenek Dohnal 640663
      # apply only if founded vim and vi are in the expected dir from distro
Zdenek Dohnal 640663
      function vi
Zdenek Dohnal 640663
        command vim $argv
Zdenek Dohnal 640663
      end
Zdenek Dohnal 640663
Zdenek Dohnal 640663
      function view
Zdenek Dohnal 640663
        command vim -R $argv
Zdenek Dohnal 640663
      end
Zdenek Dohnal 640663
  case -/usr/bin/vi
Zdenek Dohnal 640663
      # apply only when no vim is installed and founded vi is in the expected dir from distro
Zdenek Dohnal 640663
      function vim
Zdenek Dohnal 640663
        command read -p 'No vim found, using vi, press ENTER to continue' -n1 -t 20 -s && vi $argv
Zdenek Dohnal 640663
      end
Zdenek Dohnal 640663
end
Zdenek Dohnal 640663
Zdenek Dohnal 640663
# just in case
Zdenek Dohnal 640663
set -e vim_cond
Zdenek Dohnal 640663
set -e vi_cond