Create a new subpackage to set vim as a default editor

This commit is contained in:
Paweł Marciniak 2020-10-09 14:42:37 +02:00
parent de6d14a6d2
commit d8e67b2f1e
4 changed files with 41 additions and 1 deletions

5
vim-default-editor.csh Normal file
View File

@ -0,0 +1,5 @@
# Ensure vim is set as EDITOR if it isn't already set
if ( ! ($?EDITOR) ) then
setenv EDITOR "/usr/bin/vim"
endif

8
vim-default-editor.fish Normal file
View File

@ -0,0 +1,8 @@
# Ensure vim is set as EDITOR if it isn't already set
# This is set as a universal variable so that any other definition
# by the user would win
# Cf. https://fishshell.com/docs/current/index.html#variables-scope
if ! set -q EDITOR;
set -Ux EDITOR /usr/bin/vim
end

5
vim-default-editor.sh Normal file
View File

@ -0,0 +1,5 @@
# Ensure vim is set as EDITOR if it isn't already set
if [ -z "$EDITOR" ]; then
export EDITOR="/usr/bin/vim"
fi

View File

@ -21,7 +21,7 @@ Summary: The VIM editor
URL: http://www.vim.org/ URL: http://www.vim.org/
Name: vim Name: vim
Version: %{baseversion}.%{patchlevel} Version: %{baseversion}.%{patchlevel}
Release: 1%{?dist} Release: 2%{?dist}
License: Vim and MIT License: Vim and MIT
Source0: ftp://ftp.vim.org/pub/vim/unix/vim-%{baseversion}-%{patchlevel}.tar.bz2 Source0: ftp://ftp.vim.org/pub/vim/unix/vim-%{baseversion}-%{patchlevel}.tar.bz2
Source1: vim.sh Source1: vim.sh
@ -37,6 +37,9 @@ Source13: vim-spell-files.tar.bz2
%endif %endif
Source14: spec-template.new Source14: spec-template.new
Source15: macros.vim Source15: macros.vim
Source16: vim-default-editor.sh
Source17: vim-default-editor.csh
Source18: vim-default-editor.fish
Patch2002: vim-7.0-fixkeys.patch Patch2002: vim-7.0-fixkeys.patch
Patch2003: vim-7.4-specsyntax.patch Patch2003: vim-7.4-specsyntax.patch
@ -216,6 +219,15 @@ Install the vim-X11 package if you'd like to try out a version of vi
with graphics and mouse capabilities. You'll also need to install the with graphics and mouse capabilities. You'll also need to install the
vim-common package. vim-common package.
%package default-editor
Summary: Set vim as a default editor
Requires: vim-enhanced
BuildArch: noarch
Conflicts: nano-default-editor
%description default-editor
This subpackage contains files needed to set Vim as a default editor.
%prep %prep
%setup -q -b 0 -n %{vimdir} %setup -q -b 0 -n %{vimdir}
@ -519,7 +531,11 @@ 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 cp %{SOURCE1} %{buildroot}/%{_sysconfdir}/profile.d/vim.sh
cp %{SOURCE2} %{buildroot}/%{_sysconfdir}/profile.d/vim.csh cp %{SOURCE2} %{buildroot}/%{_sysconfdir}/profile.d/vim.csh
cp %{SOURCE16} %{buildroot}/%{_sysconfdir}/profile.d/vim-default-editor.sh
cp %{SOURCE17} %{buildroot}/%{_sysconfdir}/profile.d/vim-default-editor.csh
cp %{SOURCE18} %{buildroot}/%{_sysconfdir}/profile.d/vim-default-editor.fish
chmod 0644 %{buildroot}/%{_sysconfdir}/profile.d/vim.* chmod 0644 %{buildroot}/%{_sysconfdir}/profile.d/vim.*
chmod 0644 %{buildroot}/%{_sysconfdir}/profile.d/vim-default-editor.*
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
@ -785,7 +801,13 @@ touch %{buildroot}/%{_datadir}/%{name}/vimfiles/doc/tags
%dir %{_datadir}/icons/locolor/*/apps %dir %{_datadir}/icons/locolor/*/apps
%{_datadir}/icons/locolor/*/apps/* %{_datadir}/icons/locolor/*/apps/*
%files default-editor
%config(noreplace) %{_sysconfdir}/profile.d/vim-default-editor.*
%changelog %changelog
* Fri Oct 09 2020 Paweł Marciniak <sunwire+repo@gmail.com> - 2:8.2.1815-2
- A new subpackage, set vim as a default editor.
* Fri Oct 09 2020 Zdenek Dohnal <zdohnal@redhat.com> - 2:8.2.1815-1 * Fri Oct 09 2020 Zdenek Dohnal <zdohnal@redhat.com> - 2:8.2.1815-1
- patchlevel 1815 - patchlevel 1815