lfrc updated with Keymaps

This commit is contained in:
Thomas Naderer
2024-12-25 09:59:52 +01:00
parent 46ae676593
commit c31371c3b9

296
lf/lfrc
View File

@@ -30,10 +30,10 @@ set hidden
set ignorecase set ignorecase
set number set number
set relativenumber set relativenumber
set cursorpreviewfmt " " # set cursorpreviewfmt " "
set info size set info size
set dircounts set dircounts
set shell sh set shell zsh
set shellopts '-eu' set shellopts '-eu'
set ifs "\n" set ifs "\n"
set scrolloff 10 set scrolloff 10
@@ -41,17 +41,16 @@ set wrapscroll
set icons set icons
set period 1 set period 1
set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml" set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml"
set cleaner '~/.config/lf/cleaner' # set cleaner '~/.config/lf/cleaner'
set previewer '~/.config/lf/scope' set previewer '~/.config/lf/preview'
set promptfmt "\033[37;1m%d\033[0m\033[37;1m%f\033[0m" set promptfmt "\033[37;1m%d\033[0m\033[37;1m%f\033[0m"
## custom functions ----------------------------------------------------------# ## custom functions ----------------------------------------------------------#
cmd on-cd &{{ cmd on-cd &{{
# '&' commands run silently in background (which is what we want here), # '&' commands run silently in background (which is what we want here),
# but are not connected to stdout. # but are not connected to stdout.
# To make sure our escape sequence still reaches stdout we pipe it to /dev/tty # To make sure our escape sequence still reaches stdout we pipe it to /dev/tty
printf "\033]0; $(pwd | sed "s|$HOME|~|") - lf\007" > /dev/tty printf "\033]0; $(pwd | sed "s|$HOME|~|") - lf\007" > /dev/tty
}} }}
# also run at startup # also run at startup
@@ -60,19 +59,20 @@ on-cd
cmd open ${{ cmd open ${{
case $(file --mime-type "$f" -bL) in case $(file --mime-type "$f" -bL) in
text/*|application/json) $EDITOR "$fx";; text/*|application/json) $EDITOR "$fx";;
video/*|application/pdf) xdg-open "$f" & disown;; application/pdf) open -a Skim "$f" & disown;;
audio/*) mpv --audio-display=no $f ;; video/*) open -a IINA "$f" & disown;;
audio/*) ffplay -nodisp -autoexit $f ;; audio/*) mpv --audio-display=no "$f" ;;
image/*) feh -F $f & disown;; audio/*) ffplay -nodisp -autoexit "$f" ;;
*) for f in "$fx"; do xdg-open "$f"> /dev/null 2> /dev/null & done;; image/*) open -a Preview "$f" & disown;;
application/x-tex|application/x-python|application/x-shellscript|application/javascript|application/x-markdown) $EDITOR "$fx";;
*) for f in "$fx"; do open "$f" > /dev/null 2> /dev/null & done;;
esac esac
}} }}
# make new directory # make new directory
cmd mkdir %{{ cmd mkdir %{{
if [ "$1" ]; then if [ "$1" ]; then
mkdir -p -- "$@" && lf -remote "send $id select \"$1\"" mkdir -p -- "$@" && lf -remote "send $id select \"$1\""
fi fi
}} }}
#cmd mkdir ${{ #cmd mkdir ${{
@@ -84,56 +84,56 @@ cmd mkdir %{{
# make new file # make new file
cmd mkfile ${{ cmd mkfile ${{
set -f set -f
printf "\nFile Name: " printf "\nFile Name: "
read ans read ans
$EDITOR $ans $EDITOR $ans
}} }}
# make new 'root' file # make new 'root' file
cmd doasmkfile ${{ cmd doasmkfile ${{
set -f set -f
printf "\nFile Name: " printf "\nFile Name: "
read ans read ans
doas $EDITOR $ans doas $EDITOR $ans
}} }}
# make new script # make new script
cmd mkscript ${{ cmd mkscript ${{
set -f set -f
printf "\nFile Name: " printf "\nFile Name: "
read ans read ans
touch ~/Scripts/"$ans" touch ~/Scripts/"$ans"
chmod +x ~/Scripts/"$ans" chmod +x ~/Scripts/"$ans"
$EDITOR ~/Scripts/"$ans" $EDITOR ~/Scripts/"$ans"
}} }}
# change file permissions # change file permissions
cmd chmod ${{ cmd chmod ${{
set -f set -f
printf "\nMode Bits: " printf "\nMode Bits: "
read ans read ans
for file in "$fx" for file in "$fx"
do do
chmod $ans $file chmod $ans $file
done done
lf -remote 'send reload' lf -remote 'send reload'
}} }}
# make file executable # make file executable
cmd chmodx ${{ cmd chmodx ${{
for file in "$fx" for file in "$fx"
do do
chmod +x $file chmod +x $file
done done
lf -remote 'send reload' lf -remote 'send reload'
}} }}
# jump with fzf # jump with fzf
cmd fzf_jump ${{ cmd fzf_jump ${{
res="$(find . -maxdepth 3 | fzf --reverse --header='Jump to location')" res="$(find . -maxdepth 3 | fzf --reverse --header='Jump to location')"
if [ -f "$res" ]; then if [ -f "$res" ]; then
cmd="select" cmd="select"
elif [ -d "$res" ]; then elif [ -d "$res" ]; then
cmd="cd" cmd="cd"
fi fi
@@ -153,13 +153,13 @@ cmd delete ${{
cmd trash ${{ cmd trash ${{
files=$(printf "$fx" | tr '\n' ';') files=$(printf "$fx" | tr '\n' ';')
while [ "$files" ]; do while [ "$files" ]; do
# extract the substring from start of string up to delimiter. # extract the substring from start of string up to delimiter.
# this is the first "element" of the string. # this is the first "element" of the string.
file=${files%%;*} file=${files%%;*}
trash-put "$(basename "$file")" trash-put "$(basename "$file")"
# if there's only one element left, set `files` to an empty string. # if there's only one element left, set `files` to an empty string.
# this causes us to exit this `while` loop. # this causes us to exit this `while` loop.
# else, we delete the first "element" of the string from files, and move onto the next. # else, we delete the first "element" of the string from files, and move onto the next.
if [ "$files" = "$file" ]; then if [ "$files" = "$file" ]; then
files='' files=''
else else
@@ -223,9 +223,9 @@ cmd link %{{
exit 0 exit 0
fi fi
case "$mode" in case "$mode" in
# symbolically copy mode is indicating a soft link # symbolically copy mode is indicating a soft link
copy) ln -sr -t . -- "$@";; copy) ln -sr -t . -- "$@";;
# while a move mode is indicating a hard link # while a move mode is indicating a hard link
move) ln -t . -- "$@";; move) ln -t . -- "$@";;
esac esac
rm ~/.local/share/lf/files rm ~/.local/share/lf/files
@@ -252,140 +252,118 @@ cmd bulkrename $vidir
map "'" map "'"
map '"' map '"'
map , map ,
map c map c
map d map d
map e map e $ open "$PWD"
map m map m
map q map r
map r
# escape # escape
map <esc> :unselect;clear; map <esc> :unselect;clear;
# close
map ,q quit
# map : to ; # map : to ;
map ; read map ; read
map gg top map gg top
map G bottom map G bottom
# trash mappings # trash mappings
map dd trash map dd trash
map ct clear_trash map ct clear_trash
map rt restore_trash map rt restore_trash
map DD delete map DD delete
map cc cut map cc cut
map yy copy map yy copy
map p paste map p paste
map md push :mkdir<space> map md push :mkdir<space>
#map md mkdir #map md mkdir
map mf mkfile map mf mkfile
map ms mkscript map ms mkscript
map mF doasmkfile map mF doasmkfile
map ch chmod map ch chmod
map x chmodx map x chmodx
map U unselect map U unselect
map E extract map E extract
map cs wallcolor map cs wallcolor
map bg setwallpaper map bg setwallpaper
map <enter> shell map <enter> shell
map V push :!nvim<space> map V push :!nvim<space>
map YY $printf "%s" "$fx" | xclip -selection clipboard map YY $printf "%s" "$fx" | xclip -selection clipboard
map R reload map R reload
map C clear map C clear
# rename # rename
map cw rename map cw rename
map B bulkrename map B bulkrename
map A rename # at the very end map A rename # at the very end
#map c push A<c-u> # new rename #map c push A<c-u> # new rename
map I push A<c-a> # at the very beginning map I push A<c-a> # at the very beginning
map i push A<a-b><a-b><a-f> # before extention map i push A<a-b><a-b><a-f> # before extention
map a push A<a-b> # after extention map a push A<a-b> # after extention
# symlinks # symlinks
# yy (select for copy) and P to paste soft-link # yy (select for copy) and P to paste soft-link
# cc (select for cut) and P to paste hard-link # cc (select for cut) and P to paste hard-link
map P :link map P :link
## file openers ## file openers
map cv push :!nvim<space>$HOME/.config/lf/lfrc<enter> map cv push :!nvim<space>$HOME/.config/lf/lfrc<enter>
map cz push :!nvim<spade>$HOME/.config/zsh/.zshrc<enter> map cz push :!nvim<spade>$~/.config/zsh/.zshrc<enter>
map of open $f map of open $f
map ol $$PAGER "$f" map ol $$PAGER "$f"
map oq $$BROWSER "$f" map oq $$BROWSER "$f"
map ot openterm map ot openterm
map ov $$EDITOR "$f" map ov $$EDITOR "$f"
map odv $doas $EDITOR "$f" map odv $doas $EDITOR "$f"
map oz $$READER "$f" map oz $$READER "$f"
# execute current file (must be executable) # execute current file (must be executable)
#map x $$f #map x $$f
map X !$f map X !$f
## fzf ## fzf
map f $lf -remote "send $id select '$(fzf)'" map f $lf -remote "send $id select '$(fzf)'"
map F $vi $(fzf) map F $vi $(fzf)
map J fzf_jump map J fzf_jump
## fast navigation ## fast navigation
map gh cd ~ map gh cd ~
#map gD cd ~/Documents #map gD cd ~/Documents
map gD cd ~/Downloads map gD cd ~/Downloads
map gM cd ~/Media #map gP cd ~/Pictures
map gN cd ~/Notes map gt cd ~/Torrents
map gi cd ~/Notes/ict map gta cd ~/Torrents/Audiobook
map gt cd ~/Notes/trades map gtb cd ~/Torrents/Books
map gp cd ~/Notes/trades/tp
#map gP cd ~/Pictures map gc cd ~/.config
map gw cd ~/Pictures/wallpapers map ge cd /etc
map gP cd ~/Programs map gi tng
map gS cd ~/Scripts map ga tnh
map gT cd ~/Torrents
map gc cd ~/.config map go cd ~/Library/Mobile\ Documents/iCloud~md~obsidian/Documents/Privat
map gl cd ~/.local
map gs cd ~/.local/share
map g0 cd ~/.local/share/Trash/files
map g/ cd /
map ge cd /etc
map gm cd /mnt
map gu cd /usr
## fast movement ## fast movement
map Mh $mv "$f" ~ map Mh $mv "$f" ~
map MD $mv "$f" ~/Documents map MD $mv "$f" ~/Documents
#map MD $mv "$f" ~/Downloads #map MD $mv "$f" ~/Downloads
map MM $mv "$f" ~/Media map Mt $mv "$f" ~/Torrents
map MN $mv "$f" ~/Notes map Mta $mv "$f" ~/Torrents/Audiobooks
map Mi $mv "$f" ~/Notes/ict map Mtb $mv "$f" ~/Torrents/Books
map Mt $mv "$f" ~/Notes/trades/tp map Mc $mv "$f" ~/.config
map MP $mv "$f" ~/Pictures map Ml $mv "$f" ~/.local
map Mw $mv "$f" ~/Pictures/wallpapers
#map MP $mv "$f" ~/Programs
map MS $mv "$f" ~/Scripts
map MT $mv "$f" ~/Torrents
map Mc $mv "$f" ~/.config
map Ml $mv "$f" ~/.local
## fast copy ## fast copy
map Yh $cp "$f" ~ map Yh $cp "$f" ~
map YD $cp "$f" ~/Documents map YD $cp "$f" ~/Documents
#map YD $cp "$f" ~/Downloads #map YD $cp "$f" ~/Downloads
map YM $cp "$f" ~/Media map YT $cp "$f" ~/Torrents
map YN $cp "$f" ~/Notes map Yta $mv "$f" ~/Torrents/Audiobooks
map Yi $cp "$f" ~/Notes/ict map Ytb $mv "$f" ~/Torrents/Books
map Yt $cp "$f" ~/Notes/trades/tp map Yc $cp "$f" ~/.config
map YP $cp "$f" ~/Pictures map Yl $cp "$f" ~/.local
map Yw $cp "$f" ~/Pictures/wallpapers
#map YP $cp "$f" ~/Programs
map YS $cp "$f" ~/Scripts
map YT $cp "$f" ~/Torrents
map Yc $cp "$f" ~/.config
map Yl $cp "$f" ~/.local