lf/etc/lfrc.example

111 lines
3.2 KiB
Plaintext
Raw Normal View History

2016-08-13 12:49:04 +00:00
# mc alike mode (single column)
2016-09-06 22:47:08 +00:00
# You may also consider setting an alias to automatically split windows in tmux
# (e.g. "alias mc='tmux split -h lf; lf'").
2016-08-13 12:49:04 +00:00
#set ratios 1
#set nopreview
#set showinfo size
2016-09-06 22:47:08 +00:00
# set shell interpreter accordingly
# Some systems use more efficient shell implementations for non-interactive use
# (e.g. `dash`) mapped to `/bin/sh`. By setting this option here we can tell
# `lf` to use this implementation for shell commands. This can decrease the
# startup times of commands but may also change the syntax that you are used to
# (e.g. non-POSIX features provided by your regular shell).
2016-09-06 22:47:08 +00:00
#set shell /bin/sh
2016-09-06 22:47:08 +00:00
# set internal field seperator (IFS) to ':'
# This is especially useful for interactive use to automatically split file
# names in $fs and $fx. Things may behave unexpectedly so use with caution.
2016-08-27 14:17:20 +00:00
#set ifs ':'
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 showinfo none
map zs set showinfo size
map zt set showinfo time
2016-08-13 12:49:04 +00:00
2016-08-27 14:17:20 +00:00
# sort files and show the corresponding info
map sn :set sortby name; set showinfo none
map ss :set sortby size; set showinfo size
map st :set sortby time; set showinfo 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"
# 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"
# dedicated keys for file opener actions
2016-08-13 12:49:04 +00:00
map o &mimeopen "$f"
2016-08-27 14:17:20 +00:00
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/*) IFS=':'; vim $fx;;
*) IFS=':'; for f in $fx; do xdg-open "$f" &> /dev/null & done;;
esac
}}
2016-08-13 12:49:04 +00:00
# rename current file without overwrite
cmd rename $[ -e "$1" ] || mv "$f" "$1"
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)
2016-08-13 12:49:04 +00:00
cmd trash $IFS=':'; mv --backup=numbered $fx $HOME/.trash
# 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";;
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"
IFS=':'; cp $fs "$1"
tar czvf "$1.tar.gz" "$1"
rm -rf "$1"
}}