lfrc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # most things here are inherited from Luke Smith's lf settings
  2. # Basic vars
  3. set shellopts '-eu'
  4. set ifs "\n"
  5. set scrolloff 10
  6. set icons
  7. set period 1
  8. set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml"
  9. set cleaner '~/.config/lf/cleaner'
  10. set previewer '~/.config/lf/scope'
  11. # cmds/functions
  12. cmd open ${{
  13. case $(file --mime-type "$(readlink -f $f)" -b) in
  14. application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) localc $fx ;;
  15. image/vnd.djvu|application/pdf|application/octet-stream|application/postscript) setsid -f zathura $fx >/dev/null 2>&1 ;;
  16. text/*|application/json|inode/x-empty) $EDITOR $fx;;
  17. image/x-xcf) setsid -f gimp $f >/dev/null 2>&1 ;;
  18. image/svg+xml) display -- $f ;;
  19. image/*)
  20. # We use rotdir to make sure the current file is the first one imv shows,
  21. # then we pass the rest of the directory's images to imv for scrolling.
  22. rotdir "$f" | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|tif\|ico\)\(_large\)*$" |
  23. xargs -d '\n' setsid -f imv >/dev/null 2>&1 &
  24. ;;
  25. audio/*) mpv --audio-display=no $f ;;
  26. video/*) setsid -f mpv $f -quiet >/dev/null 2>&1 ;;
  27. application/vnd*) setsid -f libreoffice "$f" >/dev/null 2>&1;;
  28. application/pdf|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;;
  29. application/pgp-encrypted) $EDITOR $fx ;;
  30. xopp) devour xournalpp $f;;
  31. sc) sc-im $f;;
  32. *) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;;
  33. esac
  34. }}
  35. cmd mkdir $mkdir -p "$(echo $* | tr ' ' '\ ')"
  36. cmd extract ${{
  37. clear; tput cup $(($(tput lines)/3)); tput bold
  38. set -f
  39. printf "%s\n\t" "$fx"
  40. printf "extract?[y/N]"
  41. read ans
  42. [ $ans = "y" ] && aunpack $fx
  43. }}
  44. cmd delete ${{
  45. clear; tput cup $(($(tput lines)/3)); tput bold
  46. set -f
  47. printf "%s\n\t" "$fx"
  48. printf "delete?[y/N]"
  49. read ans
  50. [ $ans = "y" ] && rm -rf -- $fx
  51. }}
  52. cmd moveto ${{
  53. clear; tput cup $(($(tput lines)/3)); tput bold
  54. set -f
  55. clear; echo "Move to where?"
  56. dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" &&
  57. for x in $fx; do
  58. eval mv -iv \"$x\" \"$dest\"
  59. done &&
  60. notify-send "🚚 File(s) moved." "File(s) moved to $dest."
  61. }}
  62. cmd copyto ${{
  63. clear; tput cup $(($(tput lines)/3)); tput bold
  64. set -f
  65. clear; echo "Copy to where?"
  66. dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" &&
  67. for x in $fx; do
  68. eval cp -ivr \"$x\" \"$dest\"
  69. done &&
  70. notify-send "📋 File(s) copied." "File(s) copies to $dest."
  71. }}
  72. cmd setbg "$1"
  73. cmd bulkrename $vidir
  74. # Bindings
  75. map <c-f> $lf -remote "send $id select '$(fzf)'"
  76. map J $lf -remote "send $id cd $(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf)"
  77. map gh
  78. map g top
  79. map D delete
  80. map E extract
  81. map C copyto
  82. map M moveto
  83. map <c-n> push :mkdir<space>
  84. map <c-r> reload
  85. map <c-s> set hidden!
  86. map <enter> shell
  87. map x $$f
  88. map X !$f
  89. map o &mimeopen $f
  90. map O $mimeopen --ask $f
  91. map A rename # at the very end
  92. map c push A<c-u> # new rename
  93. map I push A<c-a> # at the very beginning
  94. map i push A<a-b><a-b><a-f> # before extention
  95. map a push A<a-b> # after extention
  96. map B bulkrename
  97. map b $setbg $f
  98. map <c-e> down
  99. map <c-y> up
  100. map V push :!nvim<space>
  101. map t $tesseract -l deu $f - | wl-copy
  102. map W $setsid -f $TERMINAL >/dev/null 2>&1
  103. map Y $printf "%s" "$fx" | wl-copy
  104. # Force a redraw to clear Kitty images when moving selection
  105. # cmd on-select &{{
  106. # kitten icat --clear --stdin no > /dev/tty
  107. # lf -remote "send $id redraw"
  108. # }}