bulkrename using built-ins instead of using a completely separate program (#1330)
* bulkrename using bult-ins instead of using a completely separate program * Make it more efficient
This commit is contained in:
parent
ce1f0bfa05
commit
1633233c9d
1 changed files with 21 additions and 1 deletions
|
@ -93,7 +93,27 @@ cmd copyto ${{
|
||||||
}}
|
}}
|
||||||
|
|
||||||
cmd setbg "$1"
|
cmd setbg "$1"
|
||||||
cmd bulkrename $vidir
|
|
||||||
|
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"
|
||||||
|
}}
|
||||||
|
|
||||||
# Bindings
|
# Bindings
|
||||||
map <c-f> $lf -remote "send $id select \"$(fzf)\""
|
map <c-f> $lf -remote "send $id select \"$(fzf)\""
|
||||||
|
|
Loading…
Reference in a new issue