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)"
|
||||
}
|
||||
list() {
|
||||
# 1st arg is trash files directory
|
||||
# 2nd arg is directory to match trash files for
|
||||
for file in "$1"/*; do
|
||||
[ "$(head -1 "$file")" = "[Trash Info]" ] \
|
||||
&& printf "%s %s %s\n" \
|
||||
"$(basename "$file")" \
|
||||
"$(grep Path "$file" | cut -d '=' -f2)" \
|
||||
"$(date -d "$(grep Date "$file" | cut -d '=' -f2)" +'%x %X')"
|
||||
[ "$(head -1 "$file")" = "[Trash Info]" ] && \
|
||||
fpath=$(grep Path "$file" | cut -d '=' -f2) && \
|
||||
echo "$fpath" | grep -qP "^$2" && \
|
||||
printf "%s %s %s\n" \
|
||||
"$(basename "$file")" \
|
||||
"$fpath" \
|
||||
"$(date -d "$(grep Date "$file" | cut -d '=' -f2)" +'%x %X')"
|
||||
done
|
||||
}
|
||||
|
||||
dir="${1:-$(getfsroot "$PWD")}"
|
||||
[ -n "$1" ] && dir="$(realpath "$1")" || dir="$(getfsroot "$PWD")"
|
||||
fsroot="$(getfsroot "$dir")"
|
||||
[ "$fsroot" = "$(getfsroot "${XDG_DATA_HOME:-$HOME/.local/share}")" ] \
|
||||
&& basedir="${XDG_DATA_HOME:-$HOME/.local/share}/Trash" \
|
||||
|| basedir="${fsroot}/.Trash"
|
||||
|
||||
sel="$(list "$basedir/info" | fzf)"
|
||||
sel="$(list "$basedir/info" "$dir" | fzf)"
|
||||
file="$basedir/files/$(echo "$sel" | cut -d ' ' -f1)"
|
||||
dest="$(echo "$sel" | cut -d ' ' -f2)"
|
||||
command mv -ib "$file" "$dest"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user