lfrc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. # Luke's lf settings
  2. # Note on Image Previews
  3. # For those wanting image previews, like this system, there are four steps to
  4. # set it up. These are done automatically for LARBS users, but I will state
  5. # them here for others doing it manually.
  6. #
  7. # 1. ueberzug must be installed.
  8. # 2. The scope file (~/.config/lf/scope for me), must have a command similar to
  9. # mine to generate ueberzug images.
  10. # 3. A `set cleaner` line as below is a cleaner script.
  11. # 4. lf should be started through a wrapper script (~/.local/bin/lfub for me)
  12. # that creates the environment for ueberzug. This command can be be aliased
  13. # in your shellrc (`alias lf="lfub") or if set to a binding, should be
  14. # called directly instead of normal lf.
  15. # Basic vars
  16. set shellopts '-eu'
  17. set ifs "\n"
  18. set scrolloff 10
  19. set icons
  20. set period 1
  21. set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml"
  22. set cleaner '~/.config/lf/cleaner'
  23. set previewer '~/.config/lf/scope'
  24. # cmds/functions
  25. cmd open ${{
  26. case $(file --mime-type "$(readlink -f $f)" -b) in
  27. application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) localc $fx ;;
  28. image/vnd.djvu|application/pdf|application/octet-stream|application/postscript) setsid -f zathura $fx >/dev/null 2>&1 ;;
  29. text/*|application/json|inode/x-empty) $EDITOR $fx;;
  30. image/x-xcf) setsid -f gimp $f >/dev/null 2>&1 ;;
  31. image/svg+xml) display -- $f ;;
  32. image/*) rotdir $f | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|tif\|ico\)\(_large\)*$" |
  33. setsid -f sxiv -aio 2>/dev/null | while read -r file; do
  34. [ -z "$file" ] && continue
  35. lf -remote "send select \"$file\""
  36. lf -remote "send toggle"
  37. done &
  38. ;;
  39. audio/*) mpv --audio-display=no $f ;;
  40. video/*) setsid -f mpv $f -quiet >/dev/null 2>&1 ;;
  41. application/vnd*) setsid -f libreoffice "$f" >/dev/null 2>&1;;
  42. application/pdf|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;;
  43. application/pgp-encrypted) $EDITOR $fx ;;
  44. xopp) devour xournalpp $f;;
  45. sc) sc-im $f;;
  46. *) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;;
  47. esac
  48. }}
  49. cmd mkdir $mkdir -p "$(echo $* | tr ' ' '\ ')"
  50. cmd extract ${{
  51. clear; tput cup $(($(tput lines)/3)); tput bold
  52. set -f
  53. printf "%s\n\t" "$fx"
  54. printf "extract?[y/N]"
  55. read ans
  56. [ $ans = "y" ] && aunpack $fx
  57. }}
  58. cmd delete ${{
  59. clear; tput cup $(($(tput lines)/3)); tput bold
  60. set -f
  61. printf "%s\n\t" "$fx"
  62. printf "delete?[y/N]"
  63. read ans
  64. [ $ans = "y" ] && rm -rf -- $fx
  65. }}
  66. cmd moveto ${{
  67. clear; tput cup $(($(tput lines)/3)); tput bold
  68. set -f
  69. clear; echo "Move to where?"
  70. dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" &&
  71. for x in $fx; do
  72. eval mv -iv \"$x\" \"$dest\"
  73. done &&
  74. notify-send "🚚 File(s) moved." "File(s) moved to $dest."
  75. }}
  76. cmd copyto ${{
  77. clear; tput cup $(($(tput lines)/3)); tput bold
  78. set -f
  79. clear; echo "Copy to where?"
  80. dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" &&
  81. for x in $fx; do
  82. eval cp -ivr \"$x\" \"$dest\"
  83. done &&
  84. notify-send "📋 File(s) copied." "File(s) copies to $dest."
  85. }}
  86. cmd setbg "$1"
  87. cmd bulkrename $vidir
  88. # Bindings
  89. map <c-f> $lf -remote "send $id select '$(fzf)'"
  90. 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)"
  91. map gh
  92. map g top
  93. map D delete
  94. map E extract
  95. map C copyto
  96. map M moveto
  97. map <c-n> push :mkdir<space>
  98. map <c-r> reload
  99. map <c-s> set hidden!
  100. map <enter> shell
  101. map x $$f
  102. map X !$f
  103. map o &mimeopen $f
  104. map O $mimeopen --ask $f
  105. map A rename # at the very end
  106. map c push A<c-u> # new rename
  107. map I push A<c-a> # at the very beginning
  108. map i push A<a-b><a-b><a-f> # before extention
  109. map a push A<a-b> # after extention
  110. map B bulkrename
  111. map b $setbg $f
  112. map <c-e> down
  113. map <c-y> up
  114. map V push :!nvim<space>
  115. map W $setsid -f $TERMINAL >/dev/null 2>&1
  116. map Y $printf "%s" "$fx" | xclip -selection clipboard