voidrice/.config/lf/lfrc

170 lines
5.6 KiB
Text
Raw Permalink Normal View History

2019-05-24 02:59:30 +00:00
# Luke's lf settings
2022-03-11 23:32:19 +00:00
# Note on Image Previews
# For those wanting image previews, like this system, there are four steps to
# set it up. These are done automatically for LARBS users, but I will state
# them here for others doing it manually.
#
# 1. ueberzug must be installed.
# 2. The scope file (~/.config/lf/scope for me), must have a command similar to
# mine to generate ueberzug images.
# 3. A `set cleaner` line as below is a cleaner script.
# 4. lf should be started through a wrapper script (~/.local/bin/lfub for me)
2022-03-11 23:32:19 +00:00
# that creates the environment for ueberzug. This command can be be aliased
# in your shellrc (`alias lf="lfub") or if set to a binding, should be
# called directly instead of normal lf.
2019-05-24 02:59:30 +00:00
# Basic vars
set shellopts '-eu'
set ifs "\n"
set scrolloff 10
set icons
set period 1
2020-07-10 18:20:01 +00:00
set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml"
2022-03-11 23:32:19 +00:00
set cleaner '~/.config/lf/cleaner'
set previewer '~/.config/lf/scope'
set autoquit true
2024-01-27 16:28:20 +00:00
set hidden true
2019-05-24 02:59:30 +00:00
# cmds/functions
cmd open ${{
case $(file --mime-type "$(readlink -f $f)" -b) in
2022-03-06 18:19:51 +00:00
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) localc $fx ;;
image/vnd.djvu|application/pdf|application/octet-stream|application/postscript) setsid -f zathura $fx >/dev/null 2>&1 ;;
2023-01-15 13:23:06 +00:00
text/*|application/json|inode/x-empty|application/x-subrip) $EDITOR $fx;;
2020-12-26 14:38:52 +00:00
image/x-xcf) setsid -f gimp $f >/dev/null 2>&1 ;;
image/svg+xml) display -- $f ;;
image/*) rotdir $f | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|avif\|tif\|ico\)\(_large\)*$" |
2023-07-15 16:57:12 +00:00
setsid -f nsxiv -aio 2>/dev/null | while read -r file; do
2022-03-11 23:32:19 +00:00
[ -z "$file" ] && continue
lf -remote "send select \"$file\""
lf -remote "send toggle"
done &
;;
2023-01-15 13:23:06 +00:00
audio/*|video/x-ms-asf) mpv --audio-display=no $f ;;
video/*) setsid -f mpv $f -quiet >/dev/null 2>&1 ;;
2022-11-16 16:23:03 +00:00
application/pdf|application/vnd.djvu|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;;
2021-05-31 00:55:28 +00:00
application/pgp-encrypted) $EDITOR $fx ;;
application/vnd.openxmlformats-officedocument.wordprocessingml.document|application/vnd.oasis.opendocument.text|application/vnd.openxmlformats-officedocument.spreadsheetml.sheet|application/octet-stream|application/vnd.oasis.opendocument.spreadsheet|application/vnd.oasis.opendocument.spreadsheet-template|application/vnd.openxmlformats-officedocument.presentationml.presentation|application/vnd.oasis.opendocument.presentation-template|application/vnd.oasis.opendocument.presentation|application/vnd.ms-powerpoint|application/vnd.oasis.opendocument.graphics|application/vnd.oasis.opendocument.graphics-template|application/vnd.oasis.opendocument.formula|application/vnd.oasis.opendocument.database) setsid -f libreoffice $fx >/dev/null 2>&1 ;;
*) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;;
2019-05-24 02:59:30 +00:00
esac
}}
cmd mkdir $mkdir -p "$@"
2019-05-24 02:59:30 +00:00
2021-03-30 01:32:42 +00:00
cmd extract ${{
clear; tput cup $(($(tput lines)/3)); tput bold
set -f
printf "%s\n\t" "$fx"
printf "extract?[y/N]"
read ans
[ $ans = "y" ] && {
case $fx in
*.tar.bz2) tar xjf $fx ;;
*.tar.gz) tar xzf $fx ;;
*.bz2) bunzip2 $fx ;;
*.rar) unrar e $fx ;;
*.gz) gunzip $fx ;;
*.tar) tar xf $fx ;;
*.tbz2) tar xjf $fx ;;
*.tgz) tar xzf $fx ;;
*.zip) unzip $fx ;;
*.Z) uncompress $fx ;;
*.7z) 7z x $fx ;;
*.tar.xz) tar xf $fx ;;
esac
}
2021-03-30 01:32:42 +00:00
}}
2019-05-24 02:59:30 +00:00
cmd delete ${{
clear; tput cup $(($(tput lines)/3)); tput bold
2019-05-24 02:59:30 +00:00
set -f
printf "%s\n\t" "$fx"
2019-09-23 10:14:33 +00:00
printf "delete?[y/N]"
2019-05-24 02:59:30 +00:00
read ans
2020-12-26 14:38:52 +00:00
[ $ans = "y" ] && rm -rf -- $fx
2019-05-24 02:59:30 +00:00
}}
cmd moveto ${{
clear; tput cup $(($(tput lines)/3)); tput bold
2019-05-24 02:59:30 +00:00
set -f
clear; echo "Move to where?"
2021-11-12 22:02:41 +00:00
dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" &&
2020-05-27 19:54:16 +00:00
for x in $fx; do
eval mv -iv \"$x\" \"$dest\"
done &&
2019-05-24 02:59:30 +00:00
notify-send "🚚 File(s) moved." "File(s) moved to $dest."
}}
cmd copyto ${{
clear; tput cup $(($(tput lines)/3)); tput bold
2019-05-24 02:59:30 +00:00
set -f
clear; echo "Copy to where?"
2021-11-12 22:02:41 +00:00
dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" &&
2020-05-27 19:54:16 +00:00
for x in $fx; do
eval cp -ivr \"$x\" \"$dest\"
done &&
2019-05-24 02:59:30 +00:00
notify-send "📋 File(s) copied." "File(s) copies to $dest."
}}
2020-07-16 12:27:28 +00:00
cmd setbg "$1"
cmd bulkrename ${{
tmpfile_old="$(mktemp)"
tmpfile_new="$(mktemp)"
[ -n "$fs" ] && fs=$(basename -a $fs) || fs=$(ls)
echo "$fs" > "$tmpfile_old"
echo "$fs" > "$tmpfile_new"
$EDITOR "$tmpfile_new"
[ "$(wc -l < "$tmpfile_old")" -eq "$(wc -l < "$tmpfile_new")" ] || { rm -f "$tmpfile_old" "$tmpfile_new"; exit 1; }
paste "$tmpfile_old" "$tmpfile_new" | while IFS="$(printf '\t')" read -r src dst
do
[ "$src" = "$dst" ] || [ -e "$dst" ] || mv -- "$src" "$dst"
done
rm -f "$tmpfile_old" "$tmpfile_new"
lf -remote "send $id unselect"
}}
2019-05-24 02:59:30 +00:00
# Bindings
map <c-f> $lf -remote "send $id select \"$(fzf)\""
2021-11-12 22:02:41 +00:00
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)"
2019-05-24 02:59:30 +00:00
map gh
map g top
map D delete
2021-03-30 01:32:42 +00:00
map E extract
2019-05-24 02:59:30 +00:00
map C copyto
map M moveto
map <c-n> push :mkdir<space>""<left>
2019-09-23 10:14:33 +00:00
map <c-r> reload
2021-03-30 01:32:42 +00:00
map <c-s> set hidden!
2019-05-24 02:59:30 +00:00
map <enter> shell
map x $$f
map X !$f
map o &mimeopen "$f"
map O $mimeopen --ask "$f"
2023-05-24 13:28:56 +00:00
map A :rename; cmd-end # at the very end
map c push A<c-u> # new rename
2023-05-24 13:28:56 +00:00
map I :rename; cmd-home # at the very beginning
map i :rename # before extension
map a :rename; cmd-right # after extension
map B bulkrename
2020-07-16 12:27:28 +00:00
map b $setbg $f
map <c-e> down
map <c-y> up
map V push :!nvim<space>
2021-09-23 15:30:23 +00:00
map W $setsid -f $TERMINAL >/dev/null 2>&1
2022-03-06 18:19:51 +00:00
map Y $printf "%s" "$fx" | xclip -selection clipboard
# Source Bookmarks
2021-08-25 12:02:39 +00:00
source "~/.config/lf/shortcutrc"