~ steve
/.bashrc
Gives a prompt which shows user's group if it's different from username, with a $ that turns red if the previous command exited non-zero. Also defines some aliases, plus unique package management commands.
# bash-specific shrc
# vim:fdm=marker
# define useful aliases for color codes
sh_norm="\[\033[0m\]"
sh_black="\[\033[0;30m\]"
sh_darkgray="\[\033[1;30m\]"
sh_blue="\[\033[0;34m\]"
sh_light_blue="\[\033[1;34m\]"
sh_green="\[\033[0;32m\]"
sh_light_green="\[\033[1;32m\]"
sh_cyan="\[\033[0;36m\]"
sh_light_cyan="\[\033[1;36m\]"
sh_red="\[\033[0;31m\]"
sh_light_red="\[\033[1;31m\]"
sh_purple="\[\033[0;35m\]"
sh_light_purple="\[\033[1;35m\]"
sh_brown="\[\033[0;33m\]"
sh_yellow="\[\033[1;33m\]"
sh_light_gray="\[\033[0;37m\]"
sh_white="\[\033[1;37m\]"
# whether or not we have a command
have() {
type "$1" &> /dev/null
}
# Prompt {{{
# the name of my primary (local) machine
LOCALHOST='pastorius'
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=`cat /etc/debian_chroot`
fi
GRP=$(groups |sed 's/ .*//')
if [ "$GRP" != "$USER" ]; then
prompt_group=$GRP
fi
if [ $(hostname) = $LOCALHOST ]; then
# set a green prompt for my laptop
prompt_color=$sh_light_green
else
# set a red prompt everywhere else
prompt_color=$sh_light_red
fi
# user[:group]@host:dir$
PS1='${debian_chroot:+($debian_chroot)}'${prompt_color}'\u${prompt_group:+:$prompt_group}@\h'${sh_norm}':'${sh_light_blue}'\w'${sh_norm}'${ERROR_FLAG:+'${sh_light_red}'}\$${ERROR_FLAG:+'${sh_norm}'} '
# Set an error flag to be used in our prompt.
PROMPT_COMMAND='if [ $? -ne 0 ]; then ERROR_FLAG=1; else ERROR_FLAG=; fi; '
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PROMPT_COMMAND=${PROMPT_COMMAND}' echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
;;
*)
;;
esac
# }}}
# Aliases {{{
# Color support
if [ "$TERM" != "dumb" ]; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
alias grep='grep --color'
fi
# Directory aliases
alias l='ls'
alias la='ls -a'
alias ll='ls -l'
alias lc='ls -lah'
# Other useful aliases
alias g='grep'
alias d='darcs'
alias s='sudo'
alias se='sudoedit'
# If we've got aptitude, define package aliases around it.
if have aptitude; then
alias canhas='sudo aptitude install'
alias whatz='aptitude show'
alias wherez='aptitude search'
fi
have htop && alias top='htop'
have screen && alias scr='screen -RRd'
have screen && alias scrl='screen -ls'
have vim && alias vi='vim'
# }}}
# Local config {{{
if [ -f $HOME/local/shrc ]; then
. $HOME/local/shrc
fi
# }}}
# Completion {{{
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# }}}