remove interactive prompt from profile scripts

This commit is contained in:
Zdenek Dohnal 2020-12-16 14:37:30 +01:00
parent a71f8c8cb7
commit 76de4434ca
4 changed files with 21 additions and 19 deletions

View File

@ -11,7 +11,7 @@ switch ( $vim_cond-$vi_cond )
breaksw breaksw
case -/usr/bin/vi: case -/usr/bin/vi:
# apply only if founded vi is in expected dir from distro # 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 breaksw
endsw endsw

View File

@ -16,7 +16,7 @@ switch "$vim_cond-$vi_cond"
case -/usr/bin/vi case -/usr/bin/vi
# apply only when no vim is installed and founded vi is in the expected dir from distro # apply only when no vim is installed and founded vi is in the expected dir from distro
function vim 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
end end

35
vim.sh
View File

@ -1,30 +1,31 @@
__vi_internal_vim_alias() __vi_internal_vim_alias()
( (
# if user installs vim-enanced and alias is already set # run vim if installed
test -f /usr/bin/vim && exec vim "$@" test -f /usr/bin/vim && exec /usr/bin/vim "$@"
# if user hates the "No vim found .." interrupting message # run vi otherwise
test -f "$HOME"/.i-know-vim-is-vi && exec vi "$@" test -f /usr/bin/vi && exec /usr/bin/vi "$@"
)
if [ -n "${ZSH_VERSION-}" ]; then __view_internal_vim_alias()
read -t 10 -s -k 1 '?No vim found, using vi, press ENTER to continue...' && echo '' (
else # run vim -R instead of view if vim installed
read -rep $'No vim found, using vi, press ENTER to continue...\n' -n1 -t 10 -s test -f /usr/bin/vim && exec /usr/bin/vim -R "$@"
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 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 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 # apply only when founded vim and vi are in expected dirs from distro
alias vi=vim # we need to call a shell function to avoid shell restarts when vi/vim
alias view="vim -R" # is being installed/uninstalled
;; alias vi=__vi_internal_vim_alias
-/usr/bin/vi) alias view=__view_internal_vim_alias
# apply only if founded vi is in expected dir from distro
alias vim=__vi_internal_vim_alias alias vim=__vi_internal_vim_alias
;; ;;
esac esac

View File

@ -827,6 +827,7 @@ touch %{buildroot}/%{_datadir}/%{name}/vimfiles/doc/tags
* Wed Dec 16 2020 Zdenek Dohnal <zdohnal@redhat.com> - 2:8.2.2143-2 * Wed Dec 16 2020 Zdenek Dohnal <zdohnal@redhat.com> - 2:8.2.2143-2
- make profile files as ghosts to prevent further conflicts - make profile files as ghosts to prevent further conflicts
- remove ownership of /etc/profile.d - rpmlinter reports it as an error - remove ownership of /etc/profile.d - rpmlinter reports it as an error
- remove interactive prompt from profile scripts
* Mon Dec 14 2020 Zdenek Dohnal <zdohnal@redhat.com> - 2:8.2.2143-1 * Mon Dec 14 2020 Zdenek Dohnal <zdohnal@redhat.com> - 2:8.2.2143-1
- patchlevel 2143 - patchlevel 2143