Prevent writing all marked imgs onto file (lossage)

This fix issues a warning message and does nothing in that case.

Running C-x c (copy) or C-x m (move) will copy/move all the marked files to a
single location. If that location is not a directory, then creating that file
and overwriting it several times results in complete loss of data in the case of
moving, and unhelpful behaviour in the case of "copying". Only the last marked
file remains in the file.
This commit is contained in:
Spenser Truex 2020-04-01 19:02:24 -07:00
parent 326ed6b56d
commit dfb9d7c57f

View File

@ -6,11 +6,13 @@ do
"c")
[ -z "$destdir" ] && destdir="$(sed "s/\s.*#.*$//;/^\s*$/d" ~/.config/directories | awk '{print $2}' | dmenu -l 20 -i -p "Copy file(s) to where?" | sed "s|~|$HOME|g")"
[ -z "$destdir" ] && exit
[ ! -d "$destdir" ] && notify-send "$destdir is not a directory, cancelled." && exit
cp "$file" "$destdir" && notify-send -i "$(readlink -f "$file")" "$file copied to $destdir." &
;;
"m")
[ -z "$destdir" ] && destdir="$(sed "s/\s.*#.*$//;/^\s*$/d" ~/.config/directories | awk '{print $2}' | dmenu -l 20 -i -p "Move file(s) to where?" | sed "s|~|$HOME|g")"
[ -z "$destdir" ] && exit
[ ! -d "$destdir" ] && notify-send "$destdir is not a directory, cancelled." && exit
mv "$file" "$destdir" && notify-send -i "$(readlink -f "$file")" "$file moved to $destdir." &
;;
"r")