diff --git a/vim.csh b/vim.csh index 3c95696..47df221 100644 --- a/vim.csh +++ b/vim.csh @@ -11,7 +11,7 @@ switch ( $vim_cond-$vi_cond ) breaksw case -/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' -n1 -t 20 -s && vi" + alias vim vi breaksw endsw diff --git a/vim.fish b/vim.fish index 2c20e47..a35220d 100644 --- a/vim.fish +++ b/vim.fish @@ -16,7 +16,7 @@ switch "$vim_cond-$vi_cond" case -/usr/bin/vi # apply only when no vim is installed and founded vi is in the expected dir from distro function vim - command read -p 'No vim found, using vi, press ENTER to continue' -n1 -t 20 -s && vi $argv + command vi $argv end end diff --git a/vim.sh b/vim.sh index 42282dc..2616693 100644 --- a/vim.sh +++ b/vim.sh @@ -1,30 +1,31 @@ __vi_internal_vim_alias() ( - # if user installs vim-enanced and alias is already set - test -f /usr/bin/vim && exec vim "$@" + # run vim if installed + test -f /usr/bin/vim && exec /usr/bin/vim "$@" - # if user hates the "No vim found .." interrupting message - test -f "$HOME"/.i-know-vim-is-vi && exec vi "$@" + # 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 "$@" - if [ -n "${ZSH_VERSION-}" ]; then - read -t 10 -s -k 1 '?No vim found, using vi, press ENTER to continue...' && echo '' - else - read -rep $'No vim found, using vi, press ENTER to continue...\n' -n1 -t 10 -s - fi - exec vi "$@" + # run view otherwise + test -f /usr/bin/view && exec /usr/bin/view "$@" ) 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. + # This will avoid user defined aliases case "$(command -v vim)-$(command -v vi)" in - /usr/bin/vim-/usr/bin/vi) + "/usr/bin/vim-/usr/bin/vi" | "-/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 + # 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 ;; esac diff --git a/vim.spec b/vim.spec index 0ba9b62..96168cb 100644 --- a/vim.spec +++ b/vim.spec @@ -827,6 +827,7 @@ touch %{buildroot}/%{_datadir}/%{name}/vimfiles/doc/tags * Wed Dec 16 2020 Zdenek Dohnal - 2:8.2.2143-2 - make profile files as ghosts to prevent further conflicts - remove ownership of /etc/profile.d - rpmlinter reports it as an error +- remove interactive prompt from profile scripts * Mon Dec 14 2020 Zdenek Dohnal - 2:8.2.2143-1 - patchlevel 2143