trash restore fixes
This commit is contained in:
parent
2f32b1f1c1
commit
de0d21863c
|
@ -45,7 +45,7 @@ cmd delete ${{
|
|||
[ $ans = "y" ] && rm -rf -- $fx
|
||||
}}
|
||||
|
||||
cmd trash ${{
|
||||
cmd trash %{{
|
||||
for f in $fx; do
|
||||
echo $f
|
||||
trash-put $f &
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
getfsroot() {
|
||||
printf "%s" "$(df "$1" --output=target | tail -1)"
|
||||
}
|
||||
list() {
|
||||
# 1st arg is trash files directory
|
||||
# 2nd arg is directory to match trash files for
|
||||
echo "$1 $2" > /dev/stderr
|
||||
[ ! "$(command ls -A "$1")" ] && exit 1
|
||||
for file in "$1"/*; do
|
||||
[ "$(head -1 "$file")" = "[Trash Info]" ] &&
|
||||
|
@ -19,13 +20,8 @@ list() {
|
|||
done
|
||||
}
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
dir="$(realpath "$1")"
|
||||
else
|
||||
dir="$(realpath "$PWD")"
|
||||
fi
|
||||
|
||||
fsroot="$(getfsroot "$dir")"
|
||||
fsroot="$(getfsroot "$PWD")"
|
||||
|
||||
if [ "$fsroot" = "$(getfsroot "${XDG_DATA_HOME:-$HOME/.local/share}")" ]; then
|
||||
basedir="${XDG_DATA_HOME:-$HOME/.local/share}/Trash"
|
||||
|
@ -33,7 +29,7 @@ else
|
|||
basedir="${fsroot}/.Trash"
|
||||
fi
|
||||
|
||||
sel="$(list "$basedir/info" "$dir" | fzf)"
|
||||
sel="$(list "$basedir/info" "$PWD" | fzf)"
|
||||
file="$basedir/files/$(echo "$sel" | cut -d '' -f1)"
|
||||
dest="$(echo "$sel" | cut -d '' -f3)"
|
||||
command mv -ib "$file" "$dest"
|
||||
|
|
Loading…
Reference in New Issue