Fix & improve lf's moveto, copyto and cd to bm-dir (#994)

* Changed paru to yay due to new LARBS changes

* Fix & improve lf's moveto, copyto and cd to bm-dir

When using any of the above functions they returned exit code 1. This was due to the cut command having tab as the delimiter, but spaces are used in the bm-dirs file. 
As an improvement comments are now automatically removed from the fzf options, because selecting those wouldn't work anyway.
The final sed command substituting "~" for "$HOME" is also removed because that doesn't seem to do anything looking at the current structure of the bm-dirs file.
The J bind needed more parsing and environment variable substitution because cd didn't work by default with values from a subshell.
This commit is contained in:
krisdoodle45 2021-08-31 15:28:33 +02:00 committed by GitHub
parent 9b6005292c
commit 05aa7d1182
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -52,7 +52,7 @@ cmd moveto ${{
clear; tput cup $(($(tput lines)/3)); tput bold clear; tput cup $(($(tput lines)/3)); tput bold
set -f set -f
clear; echo "Move to where?" clear; echo "Move to where?"
dest="$(cut -d' ' -f2- ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|' )" && dest="$(awk '{ gsub(/#.*/, ""); } !/^$/ { print $2 }' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf)" &&
for x in $fx; do for x in $fx; do
eval mv -iv \"$x\" \"$dest\" eval mv -iv \"$x\" \"$dest\"
done && done &&
@ -63,7 +63,7 @@ cmd copyto ${{
clear; tput cup $(($(tput lines)/3)); tput bold clear; tput cup $(($(tput lines)/3)); tput bold
set -f set -f
clear; echo "Copy to where?" clear; echo "Copy to where?"
dest="$(cut -d' ' -f2- ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|' )" && dest="$(awk '{ gsub(/#.*/, ""); } !/^$/ { print $2 }' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf)" &&
for x in $fx; do for x in $fx; do
eval cp -ivr \"$x\" \"$dest\" eval cp -ivr \"$x\" \"$dest\"
done && done &&
@ -75,7 +75,7 @@ cmd bulkrename $vidir
# Bindings # Bindings
map <c-f> $lf -remote "send $id select '$(fzf)'" map <c-f> $lf -remote "send $id select '$(fzf)'"
map J $lf -remote "send $id cd $(cut -d' ' -f2 ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf)" map J $lf -remote "send $id cd $(awk '{ gsub(/#.*/, ""); } !/^$/ { print $2 }' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed "s/\${.*-// ; s/}//" | envsubst)"
map gh map gh
map g top map g top
map D delete map D delete