diff --git a/.config/lf/lfrc b/.config/lf/lfrc index df258a7f..ee04fd5b 100644 --- a/.config/lf/lfrc +++ b/.config/lf/lfrc @@ -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 & diff --git a/.local/bin/trash-restore b/.local/bin/trash-restore index bf5bef38..6dcb96f4 100755 --- a/.local/bin/trash-restore +++ b/.local/bin/trash-restore @@ -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"