lf/etc/lfrc.example

116 lines
2.9 KiB
Plaintext
Raw Normal View History

# interpreter for shell commands (needs to be POSIX compatible)
2016-09-06 22:47:08 +00:00
#set shell /bin/sh
# set internal field separator (IFS) to "\n" for shell commands
# This is useful to automatically split file names in $fs and $fx properly
# 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
2016-08-27 14:17:20 +00:00
# easily toggle options
map zp set preview!
map zh set hidden!
# easily select what information to show
map zn set info
map zs set info size
map zt set info time
map za set info size:time
2016-08-13 12:49:04 +00:00
2016-08-27 14:17:20 +00:00
# sort files and show the corresponding info
2017-02-11 11:52:28 +00:00
map sn :set sortby natural; set info
map ss :set sortby size; set info size
map st :set sortby time; set info time
2016-08-27 14:17:20 +00:00
# common directories
map gh cd ~
map gr cd /
2016-08-13 12:49:04 +00:00
# use enter for shell commands
map <enter> read-shell
2016-08-13 12:49:04 +00:00
2016-08-27 14:17:20 +00:00
# mappings for pager and editor (change as you like)
map i $less $f
map e $vim $f
2016-08-27 14:17:20 +00:00
# mapping to spawn a shell in working directory
2016-09-06 22:47:08 +00:00
# (see also etc/lf.sh as an alternative workflow)
2016-08-27 14:17:20 +00:00
map w $$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
2016-09-13 21:49:02 +00:00
# show documentation (overrides search-back)
map ? $lf -doc | less
2016-09-06 22:47:08 +00:00
# define a custom `open-file` command
# `open-file` is called by `open` when current file is not a directory. You may
# 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
text/*) vim $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
$mkdir -p $HOME/.trash
# move current file or selected files to trash folder
2016-09-06 22:47:08 +00:00
# (see 'man mv' or 'mv --help' for backup options)
cmd trash $mv --backup=numbered $fx $HOME/.trash
2016-08-13 12:49:04 +00:00
2017-02-11 13:28:45 +00:00
# remove current file or selected files (prompting)
#cmd remove ${{
# printf "$fx\n"
# printf "remove?[y/n]"
2017-02-11 13:28:45 +00:00
# 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
# (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
}}