mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-01-30 09:48:11 +01:00
Fix dangerous copy/move script in lf (#1437)
Context: I accidentally pressed the C key on my .config directory and was presented with a list of directories to copy it to, then I pressed escape to quit the fzf menu without choosing anything - instead of doing nothing the script copied all of the contents inside my .config directory into my home directory. After dealing with that mess I decided to make this PR which does the following: - Allow users to escape out of the fzf menu without unexpected copies - Asks the user for confirmation before copying/moving files - Some improvements in the UI
This commit is contained in:
parent
628ed4dc99
commit
61026e18de
@ -92,25 +92,37 @@ cmd delete ${{
|
|||||||
}}
|
}}
|
||||||
|
|
||||||
cmd moveto ${{
|
cmd moveto ${{
|
||||||
clear; tput cup $(($(tput lines)/3)); tput bold
|
|
||||||
set -f
|
set -f
|
||||||
clear; echo "Move to where?"
|
dest=$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' "${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs" | fzf --prompt 'Move to where? ' | sed 's|~|$HOME|')
|
||||||
dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" &&
|
[ -z "$dest" ] && exit
|
||||||
|
destpath=$(eval printf '%s' \"$dest\")
|
||||||
|
clear; tput cup $(($(tput lines)/3)); tput bold
|
||||||
|
echo "From:"
|
||||||
|
echo "$fx" | sed 's/^/ /'
|
||||||
|
printf "To:\n %s\n\n\tmove?[y/N]" "$destpath"
|
||||||
|
read -r ans
|
||||||
|
[ "$ans" != "y" ] && exit
|
||||||
for x in $fx; do
|
for x in $fx; do
|
||||||
eval mv -iv \"$x\" \"$dest\"
|
mv -iv "$x" "$destpath"
|
||||||
done &&
|
done &&
|
||||||
notify-send "🚚 File(s) moved." "File(s) moved to $dest."
|
notify-send "🚚 File(s) moved." "File(s) moved to $destpath."
|
||||||
}}
|
}}
|
||||||
|
|
||||||
cmd copyto ${{
|
cmd copyto ${{
|
||||||
clear; tput cup $(($(tput lines)/3)); tput bold
|
|
||||||
set -f
|
set -f
|
||||||
clear; echo "Copy to where?"
|
dest=$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' "${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs" | fzf --prompt 'Copy to where? ' | sed 's|~|$HOME|')
|
||||||
dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" &&
|
[ -z "$dest" ] && exit
|
||||||
|
destpath=$(eval printf '%s' \"$dest\")
|
||||||
|
clear; tput cup $(($(tput lines)/3)); tput bold
|
||||||
|
echo "From:"
|
||||||
|
echo "$fx" | sed 's/^/ /'
|
||||||
|
printf "To:\n %s\n\n\tcopy?[y/N]" "$destpath"
|
||||||
|
read -r ans
|
||||||
|
[ "$ans" != "y" ] && exit
|
||||||
for x in $fx; do
|
for x in $fx; do
|
||||||
eval cp -ivr \"$x\" \"$dest\"
|
cp -ivr "$x" "$destpath"
|
||||||
done &&
|
done &&
|
||||||
notify-send "📋 File(s) copied." "File(s) copies to $dest."
|
notify-send "📋 File(s) copied." "File(s) copied to $destpath."
|
||||||
}}
|
}}
|
||||||
|
|
||||||
cmd setbg "$1"
|
cmd setbg "$1"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user