# So we need something else. Command lines and env variables sent across ssh are strictly limited.
# We could override an obscure unused LC_var, like telephone, or we could transfer a file.
# But I choose to set SendEnv and AcceptEnv ssh vars for BASH_LOGIN_SHELL.
+# In a private file, i have aliases for if $- == *i*, ssh -t, else ssh.
[[ $- != *i* && ! $SSH_CONNECTION ]] && export BASH_LOGIN_SHELL=true
+
if [[ $SSH_CONNECTION ]] \
&& [[ $- == *c* ]] \
&& [[ ! $SSH_TTY ]] \
# attempt to save multiline single commands as single history entries.
shopt -s cmdhist
+
# inside emacs fixes
if [[ $INSIDE_EMACS ]]; then
export INSIDE_EMACS
if [[ $INSIDE_EMACS ]]; then
bind 'set horizontal-scroll-mode on'
bind 'set print-completions-horizontally on'
- bind '"\C-i": self-insert'
else
# arrow keys. for other terminals, see http://unix.stackexchange.com/questions/10806/how-to-change-previous-next-word-shortcut-in-bash
if [[ $TERM == "xterm" ]]; then
alias d='builtin bg'
complete -A stopped -P '"%' -S '"' d
-alias his='history'
+alias hi='history'
# note: gksudo is recommended for X apps because it does not set the
fi
}
pf() {
+ # scratch a very annoying itch.
+ # package description width as wide as the screen, and package name field small
+ # aptitude manual can't figure out how wide emacs terminal is,
+ # of course it doesn't consult the $COLUMNS variable...
+ # and in a normal terminal, it makes the package name field ridiculously big
+ # also, remove that useless dash before the description
if [[ $EUID == 0 ]]; then
- aptitude search "$@"
+ aptitude -F "%c%a%M %p %$((COLUMNS - 30))d" -w $COLUMNS search "$@"
else
- sudo aptitude search "$@"
+ sudo aptitude -F "%c%a%M %p %$((COLUMNS - 30))d" -w $COLUMNS search "$@"
fi
}
fi
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.
# use -ll, less secure but faster.
srm () {
- srm -ll "$@"
+ command srm -ll "$@"
}
# sudo redo. be aware, this command may not work right on strange distros or earlier software
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
ps_color="$(get_term_color bold green)"
fi
fi
- PS1="${PS1/%!(*[wW]*)}$(__git_ps1 ' (%s)') \[$ps_color\]$ps_char\[$(get_term_color nocolor)\] "
+ PS1="${PS1%"${PS1#*[wW]}"}$(__git_ps1 ' (%s)') \[$ps_color\]$ps_char\[$(get_term_color nocolor)\] "
}
PROMPT_COMMAND=prompt_command
fi