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