dotfiles/.config/lf/lfrc

227 lines
4.0 KiB
Plaintext
Raw Normal View History

set drawbox
2023-05-14 05:06:12 -04:00
set icons true
set ignorecase true
# interpreter for shell commands
set shell sh
set shellopts '-eu'
set previewer ctpv
set cleaner ctpvclear
2024-01-02 12:50:00 -05:00
&ctpv -d -s $id
&ctpvquit $id
2023-05-14 05:06:12 -04:00
cmd edit-config ${{
$EDITOR ~/.config/lf/lfrc
lf -remote "send $id source ~/.config/lf/lfrc"
2023-05-14 05:06:12 -04:00
}}
cmd open &{{
case $(file --mime-type "$f" -bL) in
2023-07-10 06:53:13 -04:00
text/*|application/json) lf -remote "send $id \$$EDITOR \"$fx\"";;
image/*) swayimg -f "$f";;
audio/*) lf -remote "send $id \$mpv --audio-display=no \"$fx\" && clear";;
video/*) mpv "$f";;
application/pdf|application/epub) zathura "$f";;
2023-07-10 06:53:13 -04:00
*) xdg-open "$f";;
esac
2023-05-14 05:06:12 -04:00
}}
cmd fzf_jump ${{
res="$(find . | fzf --reverse --header='Jump to location' | sed 's/\\/\\\\/g;s/"/\\"/g')"
if [ -d "$res" ] ; then
cmd="cd"
elif [ -f "$res" ] ; then
cmd="select"
else
exit 0
fi
lf -remote "send $id $cmd \"$res\""
2023-05-14 05:06:12 -04:00
}}
2023-08-14 19:28:08 -04:00
cmd rg_search ${{
res="$( \
RG_PREFIX="rg --column --line-number --no-heading --color=always \
--smart-case "
FZF_DEFAULT_COMMAND="$RG_PREFIX ''" \
fzf --bind "change:reload:$RG_PREFIX {q} || true" \
--ansi --layout=reverse --header 'Search in files' \
| cut -d':' -f1
)"
[ ! -z "$res" ] && lf -remote "send $id select \"$res\""
2023-05-14 05:06:12 -04:00
}}
cmd unarchive ${{
set -f
case $f in
2023-07-10 06:53:13 -04:00
*.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";;
esac
2023-05-14 05:06:12 -04:00
}}
cmd tar ${{
set -f
mkdir $1
cp -r $fx $1
tar czf $1.tar.gz $1
rm -rf $1
2023-05-14 05:06:12 -04:00
}}
cmd zip ${{
set -f
mkdir $1
cp -r $fx $1
zip -r $1.zip $1
rm -rf $1
2023-05-14 05:06:12 -04:00
}}
# Trash bindings
2023-08-14 19:28:08 -04:00
cmd move-to-trash ${{
2023-05-14 05:06:12 -04:00
files=$(printf "$fx" | tr '\n' ';')
while [ "$files" ]; do
file=${files%%;*}
2023-08-14 19:28:08 -04:00
trash-put "$(basename "$file")"
if [ "$files" = "$file" ]; then
files=''
else
2023-08-14 19:28:08 -04:00
files="${files#*;}"
fi
done
}}
cmd delete-from-trash ${{
files=$(printf "$fx" | tr '\n' ';')
while [ "$files" ]; do
file=${files%%;*}
if [[ "$(pwd)" == "$HOME/.local/share/Trash/files" ]]; then
rm -rf "$file"
fi
2023-05-14 05:06:12 -04:00
if [ "$files" = "$file" ]; then
files=''
else
files="${files#*;}"
fi
done
}}
2023-07-10 06:53:13 -04:00
# cmd trash ${{
# files=$(printf "$fx" | tr '\n' ';')
# while [ "$files" ]; do
# file=${files%%;*}
# if [[ $PWD == "$HOME/.local/share/Trash/files" ]]; then
# rm -rf "$file"
# else
# trash-put "$(basename "$filename")"
# fi
#
# if [ "$files" = "$file" ]; then
# files=''
# else
# files="${files#*;}"
# fi
# done
# }}
# lfrc
2023-08-14 19:28:08 -04:00
cmd trash-restore-list ${{
ids="$(echo -ne '\n' | \
trash-restore | \
awk '$1 ~ /^[0-9]+/ {print $0}' | \
fzf --multi | \
awk '{print $1}' | \
sed -z 's/\n/,/g;s/,$/\n/')"
echo $ids | trash-restore
clear
2023-05-14 05:06:12 -04:00
}}
2023-08-14 19:28:08 -04:00
cmd restore-from-trash ${{
files=$(printf "$fx" | tr '\n' ';')
while [ "$files" ]; do
file=${files%%;*}
Id="$(echo -ne '\n'|
trash-restore ~ |
grep $(basename "$file") |
awk '{print $1}'
)"
echo $Id | trash-restore ~
if [ "$files" = "$file" ]; then
files=''
else
files="${files#*;}"
fi
done
}}
map m
map o
map n
map "'"
map '"'
map d
map e
map f
map t
2023-07-10 06:53:13 -04:00
map u
2023-08-14 19:28:08 -04:00
map a
2023-07-10 06:53:13 -04:00
map ua unarchive
2023-05-14 05:06:12 -04:00
map . set hidden!
2023-05-14 05:06:12 -04:00
map md push %mkdir<space>
2023-07-10 06:53:13 -04:00
map gp jump-prev
2023-05-14 05:06:12 -04:00
map y copy
map p paste
map x cut
map <enter> open
2023-05-14 05:06:12 -04:00
map f :fzf_jump
2023-08-14 19:28:08 -04:00
map gf :rg_search
2023-05-14 05:06:12 -04:00
map C edit-config
2024-01-02 12:50:00 -05:00
map bg %setwallpaper "$f"
2023-05-14 05:06:12 -04:00
2023-08-14 19:28:08 -04:00
map mt move-to-trash
map dt delete-from-trash
map tr restore-from-trash
map trl trash-restore-list
2023-05-14 05:06:12 -04:00
map R reload
2023-05-14 05:06:12 -04:00
map gh cd ~
map gd cd ~/Downloads
map gD cd ~/Documents
map gc cd ~/.config
map gr cd ~/repos
map gC cd ~/code
2023-05-14 05:06:12 -04:00
map gp cd ~/Pictures
map gw cd ~/Pictures/wallpapers
map gs cd ~/Pictures/screenshots
map gv cd ~/Videos
map gm cd ~/Music
2023-07-10 06:53:13 -04:00
map gA cd ~/Anime
2023-05-14 05:06:12 -04:00
map gt cd ~/.local/share/Trash/files
map tc %rm -rf ~/.local/share/Trash/files/*