mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-03-20 01:37:45 +01:00
Update trash-restore
Add ability to set dir to search in
This commit is contained in:
parent
1d1d691f3a
commit
e9097515ce
@ -4,22 +4,26 @@ 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
|
||||||
|
# 2nd arg is directory to match trash files for
|
||||||
for file in "$1"/*; do
|
for file in "$1"/*; do
|
||||||
[ "$(head -1 "$file")" = "[Trash Info]" ] \
|
[ "$(head -1 "$file")" = "[Trash Info]" ] && \
|
||||||
&& printf "%s %s %s\n" \
|
fpath=$(grep Path "$file" | cut -d '=' -f2) && \
|
||||||
"$(basename "$file")" \
|
echo "$fpath" | grep -qP "^$2" && \
|
||||||
"$(grep Path "$file" | cut -d '=' -f2)" \
|
printf "%s %s %s\n" \
|
||||||
"$(date -d "$(grep Date "$file" | cut -d '=' -f2)" +'%x %X')"
|
"$(basename "$file")" \
|
||||||
|
"$fpath" \
|
||||||
|
"$(date -d "$(grep Date "$file" | cut -d '=' -f2)" +'%x %X')"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
dir="${1:-$(getfsroot "$PWD")}"
|
[ -n "$1" ] && dir="$(realpath "$1")" || dir="$(getfsroot "$PWD")"
|
||||||
fsroot="$(getfsroot "$dir")"
|
fsroot="$(getfsroot "$dir")"
|
||||||
[ "$fsroot" = "$(getfsroot "${XDG_DATA_HOME:-$HOME/.local/share}")" ] \
|
[ "$fsroot" = "$(getfsroot "${XDG_DATA_HOME:-$HOME/.local/share}")" ] \
|
||||||
&& basedir="${XDG_DATA_HOME:-$HOME/.local/share}/Trash" \
|
&& basedir="${XDG_DATA_HOME:-$HOME/.local/share}/Trash" \
|
||||||
|| basedir="${fsroot}/.Trash"
|
|| basedir="${fsroot}/.Trash"
|
||||||
|
|
||||||
sel="$(list "$basedir/info" | fzf)"
|
sel="$(list "$basedir/info" "$dir" | fzf)"
|
||||||
file="$basedir/files/$(echo "$sel" | cut -d ' ' -f1)"
|
file="$basedir/files/$(echo "$sel" | cut -d ' ' -f1)"
|
||||||
dest="$(echo "$sel" | cut -d ' ' -f2)"
|
dest="$(echo "$sel" | cut -d ' ' -f2)"
|
||||||
command mv -ib "$file" "$dest"
|
command mv -ib "$file" "$dest"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user