2016-12-27 16:05:41 +00:00
|
|
|
# interpreter for shell commands (needs to be POSIX compatible)
|
2018-02-17 17:04:30 +00:00
|
|
|
set shell sh
|
2016-08-27 11:12:03 +00:00
|
|
|
|
2017-09-07 20:01:57 +00:00
|
|
|
# set internal field separator (IFS) to "\n" for shell commands
|
|
|
|
# This is useful to automatically split file names in $fs and $fx properly
|
2017-09-08 20:46:31 +00:00
|
|
|
# since default file separator used in these variables (i.e. 'filesep' option)
|
2017-09-07 20:01:57 +00:00
|
|
|
# is newline. You need to consider the values of these options and create your
|
|
|
|
# commands accordingly.
|
|
|
|
set ifs "\n"
|
2016-08-27 14:17:20 +00:00
|
|
|
|
2016-08-13 12:49:04 +00:00
|
|
|
# leave some space at the top and the bottom of the screen
|
|
|
|
set scrolloff 10
|
|
|
|
|
|
|
|
# use enter for shell commands
|
2018-03-27 18:23:34 +00:00
|
|
|
map <enter> shell
|
2016-08-13 12:49:04 +00:00
|
|
|
|
|
|
|
# execute current file (must be executable)
|
2017-09-07 20:01:57 +00:00
|
|
|
map x $$f
|
|
|
|
map X !$f
|
2016-08-13 12:49:04 +00:00
|
|
|
|
2016-08-24 22:12:22 +00:00
|
|
|
# dedicated keys for file opener actions
|
2017-09-07 20:01:57 +00:00
|
|
|
map o &mimeopen $f
|
|
|
|
map O $mimeopen --ask $f
|
2016-08-13 12:49:04 +00:00
|
|
|
|
2017-09-08 20:46:31 +00:00
|
|
|
# show documentation (overrides 'search-back' command)
|
2016-09-13 21:49:02 +00:00
|
|
|
map ? $lf -doc | less
|
|
|
|
|
2017-09-08 20:46:31 +00:00
|
|
|
# define a custom 'open-file' command
|
|
|
|
# 'open-file' is called by 'open' when current file is not a directory. You may
|
2016-09-06 22:47:08 +00:00
|
|
|
# want to use either file extensions and/or mime types here. Below uses an
|
|
|
|
# editor for text files and a file opener for the rest.
|
2016-08-24 22:12:22 +00:00
|
|
|
cmd open-file ${{
|
2017-09-07 20:01:57 +00:00
|
|
|
case $(file --mime-type $f -b) in
|
2017-09-08 20:46:31 +00:00
|
|
|
text/*) vi $fx;;
|
2017-09-07 20:01:57 +00:00
|
|
|
*) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;;
|
2016-08-24 22:12:22 +00:00
|
|
|
esac
|
|
|
|
}}
|
|
|
|
|
2016-08-13 12:49:04 +00:00
|
|
|
# rename current file without overwrite
|
2018-04-06 19:49:50 +00:00
|
|
|
cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
|
2016-10-15 18:46:31 +00:00
|
|
|
map r push :rename<space>
|
2016-08-13 12:49:04 +00:00
|
|
|
|
|
|
|
# make sure trash folder exists
|
2018-04-06 19:49:50 +00:00
|
|
|
%mkdir -p ~/.trash
|
2016-08-13 12:49:04 +00:00
|
|
|
|
|
|
|
# move current file or selected files to trash folder
|
2017-09-16 19:11:43 +00:00
|
|
|
# (also see 'man mv' for backup/overwrite options)
|
2018-04-06 19:49:50 +00:00
|
|
|
cmd trash %mv $fx ~/.trash
|
2016-08-13 12:49:04 +00:00
|
|
|
|
2017-02-11 13:28:45 +00:00
|
|
|
# remove current file or selected files (prompting)
|
2017-09-08 20:46:31 +00:00
|
|
|
cmd remove ${{
|
|
|
|
printf "$fx\n"
|
|
|
|
printf "remove?[y/n]"
|
|
|
|
read ans
|
|
|
|
[ $ans = "y" ] && rm -rf $fx
|
|
|
|
}}
|
2017-02-11 13:28:45 +00:00
|
|
|
|
2016-08-13 12:49:04 +00:00
|
|
|
# extract the current file with the right command
|
2016-09-06 22:47:08 +00:00
|
|
|
# (xkcd link: https://xkcd.com/1168/)
|
2018-04-06 19:49:50 +00:00
|
|
|
cmd extract %{{
|
2017-09-07 20:01:57 +00:00
|
|
|
case $f in
|
|
|
|
*.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf $f;;
|
|
|
|
*.tar.gz|*.tgz) tar xzvf $f;;
|
|
|
|
*.tar.xz|*.txz) tar xJvf $f;;
|
|
|
|
*.zip) unzip $f;;
|
|
|
|
*.rar) unrar x $f;;
|
|
|
|
*.7z) 7z x $f;;
|
2016-08-13 12:49:04 +00:00
|
|
|
esac
|
|
|
|
}}
|
|
|
|
|
2018-04-06 19:49:50 +00:00
|
|
|
# compress current file or selected files with tar and gunzip
|
|
|
|
cmd compress %{{
|
2017-09-07 20:01:57 +00:00
|
|
|
mkdir $1
|
2018-04-06 19:49:50 +00:00
|
|
|
cp -r $fx $1
|
|
|
|
tar czf $1.tar.gz $1
|
2017-09-07 20:01:57 +00:00
|
|
|
rm -rf $1
|
2016-08-13 12:49:04 +00:00
|
|
|
}}
|