rework updates script
This commit is contained in:
parent
f6d89c5b71
commit
9ff77d1f1f
3 changed files with 170 additions and 69 deletions
129
.config/lf/lfrc
129
.config/lf/lfrc
|
@ -132,27 +132,34 @@ cmd dupe &{{
|
||||||
|
|
||||||
# cmd share $curl -F"file=@$fx" https://0x0.snaile.de | xclip -r -selection c
|
# cmd share $curl -F"file=@$fx" https://0x0.snaile.de | xclip -r -selection c
|
||||||
|
|
||||||
|
# TODO: Move this to zsh config
|
||||||
cmd fzfsearch ${{
|
cmd fzfsearch ${{
|
||||||
file="$(find -L $PWD | fzf --header="Searching Filenames")"
|
file="$(find -L $PWD | fzf --header="Searching Filenames" || true)"
|
||||||
|
[ -z "$file" ] && return
|
||||||
[ -d $file ] && lf -remote "send $id cd $file" && return 0
|
[ -d $file ] && lf -remote "send $id cd $file" && return 0
|
||||||
[ -f $file ] && lf -remote "send $id select $file"
|
[ -f $file ] && lf -remote "send $id select $file"
|
||||||
}}
|
}}
|
||||||
cmd fzftags ${{
|
cmd fzftags ${{
|
||||||
file="$(cat ${XDG_DATA_HOME:-$HOME/.local/share}/lf/tags | sed 's/:\*$//' | fzf --header="Searching Tags")"
|
file="$(cat ${XDG_DATA_HOME:-$HOME/.local/share}/lf/tags | fzf --header="Searching Tags" | sed 's/:.$//' || true)"
|
||||||
|
[ -z "$file" ] && return
|
||||||
[ -d $file ] && lf -remote "send $id cd $file" && return 0
|
[ -d $file ] && lf -remote "send $id cd $file" && return 0
|
||||||
[ -f $file ] && lf -remote "send $id select $file"
|
[ -f $file ] && lf -remote "send $id select $file"
|
||||||
}}
|
}}
|
||||||
cmd fzfmarks ${{
|
cmd fzfmarks ${{
|
||||||
r="$(cat ${XDG_DATA_HOME:-$HOME/.local/share}/lf/marks | fzf --header="Searching Marks")"
|
file="$(cat ${XDG_DATA_HOME:-$HOME/.local/share}/lf/marks | fzf --header="Searching Marks" | cut -b 3- || true)"
|
||||||
file="$(cat $r | sed 's/^.://')"
|
[ -z "$file" ] && return
|
||||||
[ -d $file ] && lf -remote "send $id cd $file" && return 0
|
[ -d $file ] && lf -remote "send $id cd $file" && return 0
|
||||||
[ -f $file ] && lf -remote "send $id select $file"
|
[ -f $file ] && lf -remote "send $id select $file"
|
||||||
}}
|
}}
|
||||||
cmd fzfshortcut ${{
|
cmd fzfshortcut ${{
|
||||||
file="$(cat ${XDG_CONFIG_HOME:-$HOME/.config}/lf/shortcutrc | cut -d '"' -f2 | fzf --header="Searching Shortcuts")"
|
file="$(cat ${XDG_CONFIG_HOME:-$HOME/.config}/lf/shortcutrc | cut -d '"' -f2 | fzf --header="Searching Shortcuts")"
|
||||||
|
[ -z "$file" ] && return
|
||||||
[ -d $file ] && lf -remote "send $id cd $file" && return 0
|
[ -d $file ] && lf -remote "send $id cd $file" && return 0
|
||||||
[ -f $file ] && lf -remote "send $id select $file"
|
[ -f $file ] && lf -remote "send $id select $file"
|
||||||
}}
|
}}
|
||||||
|
# cmd fzfworkon ${{
|
||||||
|
# workon -n $(workon | fzf)
|
||||||
|
# }}
|
||||||
cmd fzfgrep ${{
|
cmd fzfgrep ${{
|
||||||
set +ue
|
set +ue
|
||||||
RG_PREFIX="rg --hidden --column --line-number --no-heading --color=always --smart-case --follow --no-ignore "
|
RG_PREFIX="rg --hidden --column --line-number --no-heading --color=always --smart-case --follow --no-ignore "
|
||||||
|
@ -187,11 +194,6 @@ cmd extract ${{
|
||||||
done
|
done
|
||||||
}}
|
}}
|
||||||
|
|
||||||
# TODO: Move this to zsh config
|
|
||||||
# cmd fzfworkon ${{
|
|
||||||
# workon -n $(workon | fzf)
|
|
||||||
# }}
|
|
||||||
|
|
||||||
cmd set_previewer %{{
|
cmd set_previewer %{{
|
||||||
if [ "${1}" = "sixel" ]; then
|
if [ "${1}" = "sixel" ]; then
|
||||||
lf -remote "send $id :set sixel; set previewer ~/.config/lf/preview/sixel"
|
lf -remote "send $id :set sixel; set previewer ~/.config/lf/preview/sixel"
|
||||||
|
@ -231,44 +233,85 @@ cmd new_lf_term &{{
|
||||||
on-cd
|
on-cd
|
||||||
|
|
||||||
# Bindings
|
# Bindings
|
||||||
map <c-c>a fzfsearch
|
clearmaps
|
||||||
map <c-c>t fzftags
|
|
||||||
map <c-c>m fzfmarks
|
|
||||||
map <c-c>f fzfshortcut
|
|
||||||
map <c-c>g fzfgrep
|
|
||||||
map T trash
|
|
||||||
map <c-t> $trash-restore $PWD
|
|
||||||
map <c-d> &rm -rf -- $fx
|
|
||||||
map <c-e> extract
|
|
||||||
map P link
|
|
||||||
# map S share
|
|
||||||
map <c-g> lazygit
|
|
||||||
map <a-g> $gdu
|
|
||||||
map <c-v> pushedit
|
|
||||||
map <c-n> push :&mkdir<space>-p<space>
|
|
||||||
map N push :&touch<space>
|
|
||||||
map <c-r> reload
|
|
||||||
map <c-s> set hidden!
|
|
||||||
map x $$f
|
|
||||||
map X !$f
|
|
||||||
map o open-with
|
|
||||||
map O $less $f
|
|
||||||
map a :rename; cmd-home # rename from beginning
|
|
||||||
map r :rename; cmd-end # rename from end
|
|
||||||
map i :rename # before extension
|
|
||||||
map c push r<c-u> # new rename
|
|
||||||
map B bulkrename
|
|
||||||
map b dupe
|
|
||||||
map u :clear; unselect
|
|
||||||
map n &echo $f | xclip -r -selection c
|
|
||||||
map <esc> quit
|
map <esc> quit
|
||||||
map g/ cd "/"
|
map <space> :toggle; down
|
||||||
map W new_lf_term
|
map <enter> shell
|
||||||
|
map <a-enter> shell-wait
|
||||||
|
map <tab>a fzfsearch
|
||||||
|
map <tab>t fzftags
|
||||||
|
map <tab>m fzfmarks
|
||||||
|
map <tab>f fzfshortcut
|
||||||
|
map <tab>g fzfgrep
|
||||||
|
map "'" mark-load
|
||||||
|
map '"' mark-save
|
||||||
|
map "$" shell
|
||||||
|
map "!" shell-wait
|
||||||
|
map "&" shell-async
|
||||||
|
map ; find-next
|
||||||
|
map , find-prev
|
||||||
|
map / search
|
||||||
|
map a :rename; cmd-home # rename from beginning
|
||||||
|
map <c-b> page-up
|
||||||
|
map b dupe
|
||||||
|
map B bulkrename
|
||||||
|
map <c-c> quit
|
||||||
|
map c push r<c-u> # new rename
|
||||||
|
map <c-d> &rm -rf -- $fx
|
||||||
|
map <c-e> scroll-down
|
||||||
map e :set user_multiedit "true" ; open; set user_multiedit "false"
|
map e :set user_multiedit "true" ; open; set user_multiedit "false"
|
||||||
map E $sudo -e $f
|
map E $sudo -e $f
|
||||||
|
map f find
|
||||||
|
map F find-back
|
||||||
|
map <c-g> lazygit
|
||||||
|
map <a-g> $gdu
|
||||||
|
map gg top
|
||||||
|
map g/ cd "/"
|
||||||
|
# WARN: do not chain any more maps to g (check shortcutrc)
|
||||||
|
map G bottom
|
||||||
|
map h updir
|
||||||
|
map i :rename; cmd-end # rename from end
|
||||||
|
map j down
|
||||||
|
map k up
|
||||||
|
map l open
|
||||||
|
map m mark-save
|
||||||
|
map <c-n> push :&mkdir<space>-p<space>
|
||||||
|
map n search-next
|
||||||
|
map N search-prev
|
||||||
|
map o open-with
|
||||||
|
map O $less $f
|
||||||
|
map p paste
|
||||||
|
map P link
|
||||||
|
map q quit
|
||||||
|
map <c-r> reload
|
||||||
|
map r :rename # before extension
|
||||||
map R $lf -remote "send $id :select \"$(readlink $f)\""
|
map R $lf -remote "send $id :select \"$(readlink $f)\""
|
||||||
# map q
|
map <c-s> set hidden!
|
||||||
# map <c-q> quit
|
map sn :set sortby natural; set info
|
||||||
|
map ss :set sortby size; set info size
|
||||||
|
map st :set sortby time; set info time
|
||||||
|
map sa :set sortby atime; set info atime
|
||||||
|
map sc :set sortby ctime; set info ctime
|
||||||
|
map se :set sortby ext; set info
|
||||||
|
map <c-t> $trash-restore $PWD
|
||||||
|
map t tag-toggle
|
||||||
|
map T trash
|
||||||
|
map u :clear; unselect
|
||||||
|
map <c-v> pushedit
|
||||||
|
map v invert
|
||||||
|
map W new_lf_term
|
||||||
|
map x $$f
|
||||||
|
map X !$f
|
||||||
|
map <c-y> scroll-down
|
||||||
|
map y copy
|
||||||
|
map Y &echo $f | xclip -r -selection c
|
||||||
|
map zh set hidden!
|
||||||
|
map zr set reverse!
|
||||||
|
map zn set info
|
||||||
|
map zs set info size
|
||||||
|
map zt set info time
|
||||||
|
map za set info size:time
|
||||||
|
|
||||||
# Load bookmark shortcuts
|
# Load bookmark shortcuts
|
||||||
source "~/.config/lf/shortcutrc"
|
source "~/.config/lf/shortcutrc"
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
map gh cd "/home/luca"
|
map gh cd "/home/luca"
|
||||||
map gch cd "/home/luca/.cache"
|
map gch cd "/home/luca/.cache"
|
||||||
map gcf cd "/home/luca/.config"
|
map gcf cd "/home/luca/.config"
|
||||||
map gdt cd "/home/luca/.local/share"
|
map gdt cd "/home/luca/.local/share"
|
||||||
map gst cd "/home/luca/.local/state"
|
map gst cd "/home/luca/.local/state"
|
||||||
map gsc cd "/home/luca/.local/bin"
|
map gsc cd "/home/luca/.local/bin"
|
||||||
map gse cd "/home/luca/.local/libexec"
|
map gse cd "/home/luca/.local/libexec"
|
||||||
map gmn cd "/mnt"
|
map gmn cd "/mnt"
|
||||||
map gco cd "/home/luca/Documents/dev"
|
map gco cd "/home/luca/Documents/dev"
|
||||||
map gdl cd "/home/luca/Downloads"
|
map gdl cd "/home/luca/Downloads"
|
||||||
map gdm cd "/home/luca/Documents"
|
map gdm cd "/home/luca/Documents"
|
||||||
map gdk cd "/home/luca/Desktop"
|
map gdk cd "/home/luca/Desktop"
|
||||||
map gms cd "/home/luca/Music"
|
map gms cd "/home/luca/Music"
|
||||||
map gpc cd "/home/luca/Pictures"
|
map gpc cd "/home/luca/Pictures"
|
||||||
map gvd cd "/home/luca/Videos"
|
map gvd cd "/home/luca/Videos"
|
||||||
map gdot cd "/home/luca/.local/share/stow/dots"
|
map gdot cd "/home/luca/.local/share/stow/dots"
|
||||||
map glg cd "/home/luca/.local/log"
|
map glg cd "/home/luca/.local/log"
|
||||||
map gsv cd "/home/luca/.local/sv"
|
map gsv cd "/home/luca/.local/sv"
|
||||||
|
|
|
@ -10,13 +10,71 @@ lf_files="$XDG_DATA_HOME/lf/shortcut-files"
|
||||||
lf_dirs="$XDG_DATA_HOME/lf/shortcut-dirs"
|
lf_dirs="$XDG_DATA_HOME/lf/shortcut-dirs"
|
||||||
lf_shortcuts="$XDG_CONFIG_HOME/lf/shortcutrc"
|
lf_shortcuts="$XDG_CONFIG_HOME/lf/shortcutrc"
|
||||||
|
|
||||||
rm -f "$lf_files" "$lf_dirs" "$lf_shortcuts" "$zsh_named_dirs" 2>/dev/null
|
find_marker() {
|
||||||
|
file=$1
|
||||||
|
for marker in \
|
||||||
|
"# @SHORTCUTS@" \
|
||||||
|
"-- @SHORTCUTS@" \
|
||||||
|
"// @SHORTCUTS@" \
|
||||||
|
"/* @SHORTCUTS@ */"
|
||||||
|
do
|
||||||
|
file=$(grep -xn "$marker" "$file")
|
||||||
|
if [ -n "$file" ]; then
|
||||||
|
echo "$file"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
eval "echo \"$(cat "$bmdirs")\"" | awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
|
zsh() {
|
||||||
printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ;
|
xargs printf "hash -d %s=%s\n"
|
||||||
printf(\"map g%s cd \42%s\42 \n\",\$1,\$2) >> \"$lf_shortcuts\" ;
|
}
|
||||||
printf(\"%s\n\",\$2) >> \"$lf_dirs\" }"
|
|
||||||
|
|
||||||
eval "echo \"$(cat "$bmfiles")\"" | awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
|
clean() {
|
||||||
printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ;
|
rm -rf "/tmp/shortcuts"
|
||||||
printf(\"%s\n\",\$2) >> \"$lf_files\" }"
|
}
|
||||||
|
|
||||||
|
write_dirs_tmp() {
|
||||||
|
mkdir -p /tmp/shortcuts
|
||||||
|
while IFS= read -r line; do
|
||||||
|
shortcut=$(echo "$line" | cut -d' ' -f1)
|
||||||
|
path=$(echo "$line" | cut -d' ' -f2); path=$(eval "echo $path")
|
||||||
|
|
||||||
|
printf "hash -d %s=%s\n" "$shortcut" "$path" >>"/tmp/shortcuts/zsh_named_dirs"
|
||||||
|
printf "map g%s cd \"%s\"\n" "$shortcut" "$path" >>"/tmp/shortcuts/lf_shortcuts"
|
||||||
|
printf "map %s" "$path" >>"/tmp/shortcuts/lf_dirs"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
write_files_tmp() {
|
||||||
|
read -r contents
|
||||||
|
mkdir -p /tmp/shortcuts
|
||||||
|
|
||||||
|
shortcut=$(echo "$contents" | cut -d' ' -f1)
|
||||||
|
path=$(echo "$contents" | cut -d' ' -f2);
|
||||||
|
|
||||||
|
printf "hash -d %s=%s\n" "$shortcut" "$path" >>"/tmp/shortcuts/zsh_named_dirs"
|
||||||
|
printf "map %s" "$path" >>"/tmp/shortcuts/lf_files"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
apply_tmp() {
|
||||||
|
cat /tmp/shortcuts/zsh_named_dirs >"$zsh_named_dirs"
|
||||||
|
cat /tmp/shortcuts/lf_shortcuts >"$lf_shortcuts"
|
||||||
|
cat /tmp/shortcuts/lf_dirs >"$lf_dirs"
|
||||||
|
cat /tmp/shortcuts/lf_files >"$lf_files"
|
||||||
|
}
|
||||||
|
|
||||||
|
read_file() {
|
||||||
|
in_file=$1
|
||||||
|
sed 's/#.*//;/^$/d' "$in_file" | tr -s ' '
|
||||||
|
}
|
||||||
|
|
||||||
|
clean
|
||||||
|
|
||||||
|
read_file "$bmdirs" | write_dirs_tmp
|
||||||
|
read_file "$bmfiles" | write_files_tmp
|
||||||
|
|
||||||
|
apply_tmp
|
||||||
|
|
||||||
|
clean
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue