vifm: Make external commands conditional on executables

Only create shortcuts for external commands if those have associated
executables on the system. If we don't have an `atool` installed, it
does not make sense to have shortcuts for invoking it - likewise for
vidir, find, and so on.
This commit is contained in:
Marty Oehme 2025-01-04 14:36:23 +01:00
parent 086ad20add
commit 6bc3f0e8c1
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -305,16 +305,21 @@ nnoremap <space>C :fzfcdhome<cr>
nnoremap <space>w :grep<space>
" external commands
" extract currently selected file(s)
noremap ,xx :!atool -x %f<cr>
" compress currently selected file(s)
noremap ,xc :!atool -a %c:r.tar.gz %f<cr>
" archive currently selected file(s)
noremap ,xa :!atool -a %c:r.tar %f<cr>
" zip currently selected file(s)
noremap ,xz :!atool -a %c:r.zip %f<cr>
" combine selected PDFs into single one (named output.pdf)
noremap ,pc :!pdftk %f cat output output.pdf
if executable('atool')
" extract currently selected file(s)
noremap ,xx :!atool -x %f<cr>
" compress currently selected file(s)
noremap ,xc :!atool -a %c:r.tar.gz %f<cr>
" archive currently selected file(s)
noremap ,xa :!atool -a %c:r.tar %f<cr>
" zip currently selected file(s)
noremap ,xz :!atool -a %c:r.zip %f<cr>
endif
if executable('pdftk')
" combine selected PDFs into single one (named output.pdf)
noremap ,pc :!pdftk %f cat output output.pdf
endif
" preview thumbnails of current folder
" select thumbnails with m/M in nsxiv
@ -323,9 +328,19 @@ nnoremap ,t :!vifm-thumbnailer -t %u %c<cr>
nnoremap ,T :!vifm-thumbnailer -r -t %u %c<cr>
" batch rename or delete files in current dir
nnoremap ,rr :!edir<cr>
nnoremap ,rf :!edir --files<cr>
nnoremap ,rd :!edir --dirs<cr>
if executable('edir')
nnoremap ,rr :!edir<cr>
nnoremap ,rf :!edir --files<cr>
nnoremap ,rd :!edir --dirs<cr>
nnoremap ,rR :!edir --all --depth=10<cr>
elseif executable('vidir')
nnoremap ,rr :!vidir<cr>
if executable('find')
nnoremap ,rf :!find . -maxdepth 1 -type f | vidir -<cr>
nnoremap ,rd :!find . -maxdepth 1 -type d | vidir -<cr>
nnoremap ,rR :!find . | vidir -<cr>
endif
endif
if executable('zoxide')
" integrate zoxide search and add any vifm-visited paths automatically