mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-03-20 01:37:45 +01:00
26 lines
747 B
Bash
26 lines
747 B
Bash
#!/bin/sh
|
|
set -e
|
|
getfsroot() {
|
|
printf "%s" "$(df "$1" --output=target | tail -1)"
|
|
}
|
|
list() {
|
|
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')"
|
|
done
|
|
}
|
|
|
|
dir="${1:-$(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)"
|
|
file="$basedir/files/$(echo "$sel" | cut -d ' ' -f1)"
|
|
dest="$(echo "$sel" | cut -d ' ' -f2)"
|
|
command mv -ib "$file" "$dest"
|