Alias view to "vim -R" when available

We already alias "vi" to "vim" when the vim-enhanced package is
installed. However, /usr/bin/view is a symlink to vi, which results in
inconsistent behavior between the two - the "vi" command runs in vim
mode, but the "view" command runs in vi mode. Alias "view" to "vim -R"
when vim-enhanced is available so that these are consistent.
This commit is contained in:
Zane Bitter 2020-07-31 14:29:21 -04:00
parent 8939c5bdb1
commit 662d92a10a
3 changed files with 6 additions and 1 deletions

View File

@ -1,6 +1,7 @@
if ( -x /usr/bin/id ) then
if ( "`/usr/bin/id -u`" > 200 ) then
alias vi vim
alias view 'vim -R'
endif
endif

1
vim.sh
View File

@ -2,4 +2,5 @@ if [ -n "${BASH_VERSION-}" -o -n "${KSH_VERSION-}" -o -n "${ZSH_VERSION-}" ]; th
[ "`/usr/bin/id -u 2>/dev/null || echo 0`" -le 200 ] && return
# for bash and zsh, only if no alias is already set
alias vi >/dev/null 2>&1 || alias vi=vim
alias view >/dev/null 2>&1 || alias view="vim -R"
fi

View File

@ -21,7 +21,7 @@ Summary: The VIM editor
URL: http://www.vim.org/
Name: vim
Version: %{baseversion}.%{patchlevel}
Release: 1%{?dist}
Release: 2%{?dist}
License: Vim and MIT
Source0: ftp://ftp.vim.org/pub/vim/unix/vim-%{baseversion}-%{patchlevel}.tar.bz2
Source1: vim.sh
@ -775,6 +775,9 @@ touch %{buildroot}/%{_datadir}/%{name}/vimfiles/doc/tags
%{_datadir}/icons/locolor/*/apps/*
%changelog
* Fri Jul 31 2020 Zane Bitter <zbitter@redhat.com> - 2:8.2.1328-2
- Alias view to "vim -R" when available
* Fri Jul 31 2020 Zdenek Dohnal <zdohnal@redhat.com> - 2:8.2.1328-1
- patchlevel 1328