+ exit "$@" 2>/dev/null
+}
+
+# trash-restore lists everything that has been trashed at or below CWD
+# This picks out files just in CWD, not subdirectories,
+# which also match grep $1, usually use $1 for a time string
+# which you get from running restore-trash once first
+pick-trash() {
+ local name x ask
+ local nth=1
+ # last condition is to not ask again for ones we skipped
+ while name="$( echo | restore-trash | gr "$PWD/[^/]\+$" | gr "$1" )" \
+ && [[ $name ]] && (( $(wc -l <<<"$name") >= nth )); do
+ name="$(echo "$name" | head -n $nth | tail -n 1 )"
+ read -p "$name [Y/n] " ask
+ if [[ ! $ask || $ask == [Yy] ]]; then
+ x=$( echo "$name" | gr -o "^\s*[0-9]*" )
+ echo $x | restore-trash > /dev/null
+ elif [[ $ask == [Nn] ]]; then
+ nth=$((nth+1))
+ else
+ return
+ fi
+ done