various improvements
[distro-setup] / .bashrc
diff --git a/.bashrc b/.bashrc
index 3484db419a8711ecee8de73e02146346583518fb..a8751e3c00d46bd2806dd56c6e341390341f8547 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -576,7 +576,30 @@ q() { # start / launch a program in the backround and redir output to null
 
 
 r() {
-    exit "$@"
+    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
 }
 
 # rsync, root is required to keep permissions right.
@@ -883,10 +906,10 @@ if [[ $- == *i* ]]; then
                ps_char='\$'
                ;;
            1) ps_color="$(get_term_color green)"
-               ps_char=$return
+               ps_char="$return \\$"
                ;;
            *) ps_color="$(get_term_color yellow)"
-               ps_char=$return
+               ps_char="$return \\$"
                ;;
         esac
         if [[ ! -O . ]]; then # not owner