lf/etc/lfrc.example

89 lines
2.3 KiB
Plaintext
Raw Normal View History

# interpreter for shell commands (needs to be POSIX compatible)
set shell sh
# 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)
# 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
map <enter> shell
2016-08-13 12:49:04 +00:00
# execute current file (must be executable)
map x $$f
map X !$f
2016-08-13 12:49:04 +00:00
# dedicated keys for file opener actions
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.
cmd open-file ${{
case $(file --mime-type $f -b) in
2017-09-08 20:46:31 +00:00
text/*) vi $fx;;
*) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;;
esac
}}
2016-08-13 12:49:04 +00:00
# rename current file without overwrite
cmd rename ${{
if [ -e $1 ]; then
lf -remote "send $id echo file exists"
else
mv $f $1
fi
}}
map r push :rename<space>
2016-08-13 12:49:04 +00:00
# show disk usage
cmd usage $du -h . | less
# make sure trash folder exists
2017-09-08 20:46:31 +00:00
$mkdir -p ~/.trash
2016-08-13 12:49:04 +00:00
# move current file or selected files to trash folder
# (also see 'man mv' for backup/overwrite options)
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/)
2016-08-13 12:49:04 +00:00
cmd extract ${{
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
}}
2016-09-06 22:47:08 +00:00
# compress marked files with tar and gunzip
# This command takes the output name without '.tar.gz' suffix as an argument
2017-09-08 20:46:31 +00:00
# (e.g. 'compress foo' creates 'foo.tar.gz').
2016-08-13 12:49:04 +00:00
cmd compress ${{
mkdir $1
cp $fs $1
tar czvf $1.tar.gz $1
rm -rf $1
2016-08-13 12:49:04 +00:00
}}