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