various improvements
authorIan Kelling <ian@iankelling.org>
Tue, 27 May 2014 03:08:16 +0000 (20:08 -0700)
committerIan Kelling <ian@iankelling.org>
Thu, 4 May 2017 23:40:14 +0000 (16:40 -0700)
.bashrc
path_add-function

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
index cc613672b9790c7049eefbac6f837bbfe521b8b0..6f06ed9b2c95dba2766fda574750ca04b3737759 100644 (file)
@@ -24,7 +24,9 @@ path_add() {
         unset IFS
         if ! $found; then
             if ! $ifexists || [ -d $x ]; then
-                if $start; then
+                if [ ! "$PATH" ]; then
+                    PATH="$x"
+                elif $start; then
                     PATH="$x:$PATH"
                 else
                     PATH="$PATH:$x"