1
0
mirror of https://github.com/alrayyes/dotfiles/ synced 2023-11-14 15:56:30 +00:00
dotfiles/lfcd/.config/lf/lfrc

182 lines
3.1 KiB
Plaintext
Raw Normal View History

2020-03-13 19:45:21 +00:00
# Basic settings
set shell sh
set preview false
2019-09-30 16:09:51 +00:00
set icons on
2020-03-13 19:45:21 +00:00
set hidden true
set drawbox true
set ignorecase true
2019-09-30 16:09:51 +00:00
2020-03-13 19:45:21 +00:00
# Custom functions
2019-09-30 16:09:51 +00:00
cmd open ${{
2020-03-13 19:45:21 +00:00
case $(file --mime-type "$f" -bL) in
text/*|application/json) nvim "$f";;
video/*|image/*/application/pdf) xdg-open "$f" & disown;;
*) xdg-open "$f" ;;
2019-09-30 16:09:51 +00:00
esac
}}
2020-03-13 19:45:21 +00:00
cmd mkdir ${{
printf "Directory Name: "
read ans
mkdir $ans
}}
2019-09-30 16:09:51 +00:00
2020-03-13 19:45:21 +00:00
cmd mkfile ${{
printf "File Name: "
read ans
2020-03-14 12:26:30 +00:00
nvim $ans
2020-03-13 19:45:21 +00:00
}}
2019-09-30 16:09:51 +00:00
2020-03-13 19:45:21 +00:00
cmd chmod ${{
printf "Mode Bits: "
read ans
2019-09-30 16:09:51 +00:00
2020-03-13 19:45:21 +00:00
for file in "$fx"
do
chmod $ans $file
done
}}
2019-09-30 16:09:51 +00:00
2020-03-14 12:26:30 +00:00
cmd doasmkfile ${{
2020-03-13 19:45:21 +00:00
printf "File Name: "
read ans
2020-03-14 12:26:30 +00:00
doas nvim $ans
2019-09-30 16:09:51 +00:00
}}
2020-03-13 19:45:21 +00:00
cmd broot_jump ${{
f=$(mktemp)
res="$(broot --outcmd $f && cat $f | sed 's/cd //')"
rm -f "$f"
if [ -f "$res" ]; then
cmd="select"
elif [ -d "$res" ]; then
cmd="cd"
fi
lf -remote "send $id $cmd \"$res\""
2019-09-30 16:09:51 +00:00
}}
2020-03-13 19:45:21 +00:00
# Archive bindings
cmd extract ${{
case "$f" in
*.zip) unzip "$f" ;;
*.tar.gz) tar -xzvf "$f" ;;
*.tar.bz2) tar -xjvf "$f" ;;
*.tar) tar -xvf "$f" ;;
*) echo "Unsupported format" ;;
esac
2019-09-30 16:09:51 +00:00
}}
2020-03-13 19:45:21 +00:00
2020-03-14 12:26:30 +00:00
# View image
cmd viewimage ${{
2020-03-14 11:23:52 +00:00
if [ -d "$f" ]; then
sxiv -q -f -t "$f"
else
sxiv -q -f "$f"
fi
}}
2020-03-14 12:26:30 +00:00
# Show progress bar for file copies
cmd paste &{{
load=$(lf -remote 'load')
mode=$(echo "$load" | sed -n '1p')
list=$(echo "$load" | sed '1d')
if [ $mode = 'copy' ]; then
rsync -av --ignore-existing --progress $list . \
| stdbuf -i0 -o0 -e0 tr '\r' '\n' \
| while read line; do
lf -remote "send $id echo $line"
done
elif [ $mode = 'move' ]; then
mv -n $list .
fi
lf -remote 'send load'
lf -remote 'send clear'
}}
2020-03-13 19:45:21 +00:00
cmd zip %zip -r "$f" "$f"
cmd tar %tar cvf "$f.tar" "$f"
cmd targz %tar cvzf "$f.tar.gz" "$f"
cmd tarbz2 %tar cjvf "$f.tar.bz2" "$f"
2020-03-14 12:26:30 +00:00
# Trash cli bindings
cmd trash ${{
files=$(echo "$fx" | sed "s/ /\\\ /g;s/\[/\\\[/g;s/\]/\\\]/g")
IFS=$'\n'
for file in $files
do
trash-put "$(basename "$file")"
done
}}
cmd clear_trash %trash-empty
cmd restore_trash ${{
trash-restore
}}
2020-03-13 19:45:21 +00:00
# Bindings
# Remove some defaults
map m
map o
map n
map "'"
map '"'
map d
map c
map e
map f
# File Openers
2020-03-14 12:26:30 +00:00
map ee nvim "$f"
2020-03-13 19:45:21 +00:00
# Archive Mappings
map az zip
map at tar
map ag targz
map ab targz
map ae extract
2020-03-14 12:26:30 +00:00
# Trash Mappings
map dd trash
map tc clear_trash
map tr restore_trash
2020-03-13 19:45:21 +00:00
# Broot Mapping
map f broot_jump
# Basic Functions
map . set hidden!
map DD delete
map p paste
map x cut
map y copy
map <enter> open
map mf mkfile
2020-03-14 12:26:30 +00:00
map mr doasmkfile
2020-03-13 19:45:21 +00:00
map md mkdir
map ch chmod
map o open_config
map r rename
map H top
map L bottom
map R reload
map C clear
map U unselect
map i viewimage
2020-03-13 19:45:21 +00:00
# Movement
map gd. cd ~/Documents
map gD cd ~/Downloads
map gdbb cd ~/Documents/Business/Boekhouding
map gdbi cd ~/Documents/Business/Interne\ zaken
map gdf cd ~/Documents/Finances
map gddd cd ~/Documents/Data\ Dumps
map gdl cd ~/Documents/ledger
map gdo cd ~/Documents/org
map gs cd ~/Sync
map gm. cd ~/music
map gw. cd ~/Pictures/wallpaper/
map gww cd ~/Pictures/wallpaper/Wallpaper
map gws cd ~/Pictures/wallpaper/Wallpaper\ Small
map gw9 cd ~/Pictures/wallpaper/Wallpaper\ 90