From: Ian Kelling Date: Tue, 27 May 2014 03:08:16 +0000 (-0700) Subject: various improvements X-Git-Url: https://iankelling.org/git/?p=distro-setup;a=commitdiff_plain;h=092d1247e89b392796698570ef03c7e60ece7702 various improvements --- diff --git a/.bashrc b/.bashrc index 3484db4..a8751e3 100644 --- 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 diff --git a/path_add-function b/path_add-function index cc61367..6f06ed9 100644 --- a/path_add-function +++ b/path_add-function @@ -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"