oberblastmeister / trashy

a cli system trash manager, alternative to rm and trash-cli
Apache License 2.0
344 stars 12 forks source link

Ugly exit from fzf integration #110

Open AvianAnalyst opened 9 months ago

AvianAnalyst commented 9 months ago

With the provided fzf integration commands, if you run one, but decide to abort the operation, you have to quit twice. Is there a better solution for this?

SaHHiiLL commented 8 months ago

Had the same issues, solved it with this

list=$(trash list | fzf --multi)
if [[ -n $list ]]; then
    echo $list | awk '{$1=$1;print}' | rev | cut -d ' ' -f1 | rev | xargs trash restore --match=exact --force
else
    echo "Aborted"
fi
AvianAnalyst commented 7 months ago

Thank you! sorry for the slow reply. I'm trying to try this out but im unclear. is this verbatim an alias? or a function? specifically unsure how the if block is connected into the previous line. or is the whole thing just the function body?

SaHHiiLL commented 7 months ago

it's upto you how you want to use it. You can inline everything and alias it or wrap it in a script/function.

the if block just checks whether $list is empty or not

PS: i noted there a missing whitespace in the example above. fix: [[ -n $list ]];