vim.sh, vim.csh - set aliases only for OS default vi and vim
Do not set them for locally built vi/vim or replace existing aliases.
This commit is contained in:
parent
cbc7da83e9
commit
17062c8b2d
25
vim.csh
25
vim.csh
@ -1,7 +1,20 @@
|
|||||||
if ( -x /usr/bin/id ) then
|
# we need to use which twice - first for checking if
|
||||||
if ( "`/usr/bin/id -u`" > 200 ) then
|
# the command doesn't fail, the use it if doesn't fail
|
||||||
alias vi vim
|
set vim_cond = `which vim >& /dev/null && which vim`
|
||||||
alias view 'vim -R'
|
set vi_cond = `which vi >& /dev/null && which vi`
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
switch ( $vim_cond-$vi_cond )
|
||||||
|
case /usr/bin/vim-/usr/bin/vi:
|
||||||
|
# apply only when founded vim and vi are in expected dirs from distro
|
||||||
|
alias vi vim
|
||||||
|
alias view 'vim -R'
|
||||||
|
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"
|
||||||
|
breaksw
|
||||||
|
endsw
|
||||||
|
|
||||||
|
# just in case
|
||||||
|
unset vim_cond
|
||||||
|
unset vi_cond
|
||||||
|
16
vim.sh
16
vim.sh
@ -1,6 +1,14 @@
|
|||||||
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
|
||||||
[ "`/usr/bin/id -u 2>/dev/null || echo 0`" -le 200 ] && return
|
# This will avoid user defined aliases and possibly stuff defined earlier in the PATH.
|
||||||
# for bash and zsh, only if no alias is already set
|
case "$(which vim 2> /dev/null)-$(which vi 2> /dev/null)" in
|
||||||
alias vi >/dev/null 2>&1 || alias vi=vim
|
/usr/bin/vim-/usr/bin/vi)
|
||||||
alias view >/dev/null 2>&1 || alias view="vim -R"
|
# 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
|
||||||
|
alias vim="read -rep $'No vim found, using vi, press ENTER to continue\n' -n1 -t 20 -s && vi"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
53
vim.spec
53
vim.spec
@ -98,8 +98,8 @@ Summary: The common files needed by any version of the VIM editor
|
|||||||
Conflicts: man-pages-fr < 0.9.7-14
|
Conflicts: man-pages-fr < 0.9.7-14
|
||||||
Conflicts: man-pages-it < 0.3.0-17
|
Conflicts: man-pages-it < 0.3.0-17
|
||||||
Conflicts: man-pages-pl < 0.24-2
|
Conflicts: man-pages-pl < 0.24-2
|
||||||
Requires: %{name}-filesystem
|
|
||||||
Conflicts: %{name}-minimal < %{epoch}:8.1.1-1
|
Conflicts: %{name}-minimal < %{epoch}:8.1.1-1
|
||||||
|
Requires: %{name}-filesystem
|
||||||
|
|
||||||
%description common
|
%description common
|
||||||
VIM (VIsual editor iMproved) is an updated and improved version of the
|
VIM (VIsual editor iMproved) is an updated and improved version of the
|
||||||
@ -122,10 +122,14 @@ many different languages.
|
|||||||
|
|
||||||
%package minimal
|
%package minimal
|
||||||
Summary: A minimal version of the VIM editor
|
Summary: A minimal version of the VIM editor
|
||||||
Provides: vi
|
|
||||||
Provides: %{_bindir}/vi
|
|
||||||
# conflicts in package because of manpage move (bug #1599663)
|
# conflicts in package because of manpage move (bug #1599663)
|
||||||
Conflicts: %{name}-common < %{epoch}:8.1.1-1
|
Conflicts: %{name}-common < %{epoch}:8.1.1-1
|
||||||
|
# now vim-minimal ships vim.sh, vim.csh and vim.fish too, so we need to conflict
|
||||||
|
Conflicts: vim-enhanced < 2:8.2.1815-2
|
||||||
|
Provides: vi
|
||||||
|
Provides: %{_bindir}/vi
|
||||||
|
# needed for profile script
|
||||||
|
Requires: which
|
||||||
|
|
||||||
%description minimal
|
%description minimal
|
||||||
VIM (VIsual editor iMproved) is an updated and improved version of the
|
VIM (VIsual editor iMproved) is an updated and improved version of the
|
||||||
@ -138,10 +142,17 @@ only available when the vim-common package is installed.
|
|||||||
|
|
||||||
%package enhanced
|
%package enhanced
|
||||||
Summary: A version of the VIM editor which includes recent enhancements
|
Summary: A version of the VIM editor which includes recent enhancements
|
||||||
Requires: vim-common = %{epoch}:%{version}-%{release} which
|
# now vim-minimal ships vim.sh, vim.csh and vim.fish too, so we need to conflict
|
||||||
|
Conflicts: vim-minimal < 2:8.2.1815-2
|
||||||
|
# vim bundles libvterm, which is used during build - so we need to provide
|
||||||
|
# bundled libvterm for catching possible libvterm CVEs
|
||||||
|
Provides: bundled(libvterm)
|
||||||
Provides: vim
|
Provides: vim
|
||||||
Provides: %{_bindir}/mergetool
|
Provides: %{_bindir}/mergetool
|
||||||
Provides: %{_bindir}/vim
|
Provides: %{_bindir}/vim
|
||||||
|
Requires: vim-common = %{epoch}:%{version}-%{release} which
|
||||||
|
# needed for profile script
|
||||||
|
Requires: which
|
||||||
# suggest python3, python2, lua, ruby and perl packages because of their
|
# suggest python3, python2, lua, ruby and perl packages because of their
|
||||||
# embedded functionality in Vim/GVim
|
# embedded functionality in Vim/GVim
|
||||||
Suggests: python3 python3-libs
|
Suggests: python3 python3-libs
|
||||||
@ -152,9 +163,6 @@ Suggests: ruby-libs ruby
|
|||||||
%if "%{withlua}" == "1"
|
%if "%{withlua}" == "1"
|
||||||
Suggests: lua-libs
|
Suggests: lua-libs
|
||||||
%endif
|
%endif
|
||||||
# vim bundles libvterm, which is used during build - so we need to provide
|
|
||||||
# bundled libvterm for catching possible libvterm CVEs
|
|
||||||
Provides: bundled(libvterm)
|
|
||||||
|
|
||||||
%description enhanced
|
%description enhanced
|
||||||
VIM (VIsual editor iMproved) is an updated and improved version of the
|
VIM (VIsual editor iMproved) is an updated and improved version of the
|
||||||
@ -181,6 +189,7 @@ packages that add vim files, p.e. additional syntax files or filetypes.
|
|||||||
Summary: The VIM version of the vi editor for the X Window System - GVim
|
Summary: The VIM version of the vi editor for the X Window System - GVim
|
||||||
# needed in configure script to have correct macros enabled for GUI (#1603272)
|
# needed in configure script to have correct macros enabled for GUI (#1603272)
|
||||||
BuildRequires: gtk3-devel
|
BuildRequires: gtk3-devel
|
||||||
|
BuildRequires: libappstream-glib
|
||||||
# for sound support
|
# for sound support
|
||||||
BuildRequires: libcanberra-devel
|
BuildRequires: libcanberra-devel
|
||||||
BuildRequires: libX11-devel
|
BuildRequires: libX11-devel
|
||||||
@ -189,12 +198,11 @@ BuildRequires: libXt-devel
|
|||||||
BuildRequires: libXpm-devel
|
BuildRequires: libXpm-devel
|
||||||
BuildRequires: libICE-devel
|
BuildRequires: libICE-devel
|
||||||
|
|
||||||
Requires: vim-common = %{epoch}:%{version}-%{release} libattr >= 2.4 gtk3
|
|
||||||
Provides: gvim
|
Provides: gvim
|
||||||
Provides: %{_bindir}/mergetool
|
Provides: %{_bindir}/mergetool
|
||||||
Provides: %{_bindir}/gvim
|
Provides: %{_bindir}/gvim
|
||||||
BuildRequires: gtk3-devel libSM-devel libXt-devel libXpm-devel libappstream-glib
|
|
||||||
Requires: hicolor-icon-theme
|
Requires: hicolor-icon-theme
|
||||||
|
Requires: vim-common = %{epoch}:%{version}-%{release} libattr >= 2.4 gtk3
|
||||||
# suggest python3, python2, lua, ruby and perl packages because of their
|
# suggest python3, python2, lua, ruby and perl packages because of their
|
||||||
# embedded functionality in Vim/GVim
|
# embedded functionality in Vim/GVim
|
||||||
Suggests: python3 python3-libs
|
Suggests: python3 python3-libs
|
||||||
@ -221,12 +229,12 @@ vim-common package.
|
|||||||
|
|
||||||
%package default-editor
|
%package default-editor
|
||||||
Summary: Set vim as the default editor
|
Summary: Set vim as the default editor
|
||||||
Requires: vim-enhanced
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
Provides: system-default-editor
|
|
||||||
Conflicts: system-default-editor
|
Conflicts: system-default-editor
|
||||||
# conflict with nano-default-editor which doesn't provide system-default-editor
|
# conflict with nano-default-editor which doesn't provide system-default-editor
|
||||||
Conflicts: nano-default-editor < 5.3-3
|
Conflicts: nano-default-editor < 5.3-3
|
||||||
|
Provides: system-default-editor
|
||||||
|
Requires: vim-enhanced
|
||||||
|
|
||||||
%description default-editor
|
%description default-editor
|
||||||
This subpackage contains files needed to set Vim as the default editor.
|
This subpackage contains files needed to set Vim as the default editor.
|
||||||
@ -532,15 +540,12 @@ chmod 644 %{buildroot}/%{_datadir}/%{name}/%{vimdir}/doc/vim2html.pl \
|
|||||||
chmod 644 ../runtime/doc/vim2html.pl
|
chmod 644 ../runtime/doc/vim2html.pl
|
||||||
|
|
||||||
mkdir -p %{buildroot}/%{_sysconfdir}/profile.d
|
mkdir -p %{buildroot}/%{_sysconfdir}/profile.d
|
||||||
cp %{SOURCE1} %{buildroot}/%{_sysconfdir}/profile.d/vim.sh
|
install -p -m644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/profile.d/vim.sh
|
||||||
cp %{SOURCE2} %{buildroot}/%{_sysconfdir}/profile.d/vim.csh
|
install -p -m644 %{SOURCE2} %{buildroot}/%{_sysconfdir}/profile.d/vim.csh
|
||||||
cp %{SOURCE16} %{buildroot}/%{_sysconfdir}/profile.d/vim-default-editor.sh
|
install -p -m644 %{SOURCE16} %{buildroot}/%{_sysconfdir}/profile.d/vim-default-editor.sh
|
||||||
cp %{SOURCE17} %{buildroot}/%{_sysconfdir}/profile.d/vim-default-editor.csh
|
install -p -m644 %{SOURCE17} %{buildroot}/%{_sysconfdir}/profile.d/vim-default-editor.csh
|
||||||
chmod 0644 %{buildroot}/%{_sysconfdir}/profile.d/vim.*
|
|
||||||
chmod 0644 %{buildroot}/%{_sysconfdir}/profile.d/vim-default-editor.*
|
|
||||||
mkdir -p %{buildroot}/%{_datadir}/fish/vendor_conf.d/
|
mkdir -p %{buildroot}/%{_datadir}/fish/vendor_conf.d/
|
||||||
cp %{SOURCE18} %{buildroot}/%{_datadir}/fish/vendor_conf.d/vim-default-editor.fish
|
install -p -m644 %{SOURCE18} %{buildroot}/%{_datadir}/fish/vendor_conf.d/vim-default-editor.fish
|
||||||
chmod 0644 %{buildroot}/%{_datadir}/fish/vendor_conf.d/vim-default-editor.fish
|
|
||||||
install -p -m644 %{SOURCE4} %{buildroot}/%{_sysconfdir}/virc
|
install -p -m644 %{SOURCE4} %{buildroot}/%{_sysconfdir}/virc
|
||||||
install -p -m644 %{SOURCE5} %{buildroot}/%{_sysconfdir}/vimrc
|
install -p -m644 %{SOURCE5} %{buildroot}/%{_sysconfdir}/vimrc
|
||||||
|
|
||||||
@ -739,6 +744,8 @@ touch %{buildroot}/%{_datadir}/%{name}/vimfiles/doc/tags
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%files minimal
|
%files minimal
|
||||||
|
%dir %{_sysconfdir}/profile.d/
|
||||||
|
%config(noreplace) %{_sysconfdir}/profile.d/vim.*
|
||||||
%config(noreplace) %{_sysconfdir}/virc
|
%config(noreplace) %{_sysconfdir}/virc
|
||||||
%{_bindir}/ex
|
%{_bindir}/ex
|
||||||
%{_bindir}/vi
|
%{_bindir}/vi
|
||||||
@ -753,11 +760,12 @@ touch %{buildroot}/%{_datadir}/%{name}/vimfiles/doc/tags
|
|||||||
%{_mandir}/man5/virc.*
|
%{_mandir}/man5/virc.*
|
||||||
|
|
||||||
%files enhanced
|
%files enhanced
|
||||||
|
%dir %{_sysconfdir}/profile.d/
|
||||||
|
%config(noreplace) %{_sysconfdir}/profile.d/vim.*
|
||||||
%{_bindir}/vim
|
%{_bindir}/vim
|
||||||
%{_bindir}/rvim
|
%{_bindir}/rvim
|
||||||
%{_bindir}/vimdiff
|
%{_bindir}/vimdiff
|
||||||
%{_bindir}/vimtutor
|
%{_bindir}/vimtutor
|
||||||
%config(noreplace) %{_sysconfdir}/profile.d/vim.*
|
|
||||||
|
|
||||||
%files filesystem
|
%files filesystem
|
||||||
%{_rpmconfigdir}/macros.d/macros.vim
|
%{_rpmconfigdir}/macros.d/macros.vim
|
||||||
@ -807,14 +815,15 @@ touch %{buildroot}/%{_datadir}/%{name}/vimfiles/doc/tags
|
|||||||
%{_datadir}/icons/locolor/*/apps/*
|
%{_datadir}/icons/locolor/*/apps/*
|
||||||
|
|
||||||
%files default-editor
|
%files default-editor
|
||||||
|
%dir %{_datadir}/fish/vendor_conf.d
|
||||||
|
%{_datadir}/fish/vendor_conf.d/vim-default-editor.fish
|
||||||
%dir %{_sysconfdir}/profile.d
|
%dir %{_sysconfdir}/profile.d
|
||||||
%config(noreplace) %{_sysconfdir}/profile.d/vim-default-editor.*
|
%config(noreplace) %{_sysconfdir}/profile.d/vim-default-editor.*
|
||||||
%dir %{_datadir}/fish/vendor_conf.d
|
|
||||||
%config(noreplace) %{_datadir}/fish/vendor_conf.d/vim-default-editor.fish
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Thu Oct 15 2020 Zdenek Dohnal <zdohnal@redhat.com> - 2:8.2.1815-2
|
* Thu Oct 15 2020 Zdenek Dohnal <zdohnal@redhat.com> - 2:8.2.1815-2
|
||||||
- vim-default-editor.fish - dont give EDITOR universal scope
|
- vim-default-editor.fish - dont give EDITOR universal scope
|
||||||
|
- vim.sh, vim.csh - set aliases only for OS default vi and vim
|
||||||
|
|
||||||
* Mon Oct 12 2020 Zdenek Dohnal <zdohnal@redhat.com> - 2:8.2.1815-2
|
* Mon Oct 12 2020 Zdenek Dohnal <zdohnal@redhat.com> - 2:8.2.1815-2
|
||||||
- fix installing fish profile, set virtual provide for default editor
|
- fix installing fish profile, set virtual provide for default editor
|
||||||
|
Loading…
Reference in New Issue
Block a user