1
0
Fork 0

trash restore fixes

This commit is contained in:
Luca Bilke 2023-11-21 15:17:44 +01:00
parent 2f32b1f1c1
commit de0d21863c
2 changed files with 5 additions and 9 deletions

View File

@ -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 &

View File

@ -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"