Skip to content

Instantly share code, notes, and snippets.

@insom
Created September 12, 2011 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save insom/1211342 to your computer and use it in GitHub Desktop.
Save insom/1211342 to your computer and use it in GitHub Desktop.
Darren's Bash RC
# Color codes
RED='\[\033[01;31m\]'
GREEN='\[\033[01;32m\]'
YELLOW='\[\033[01;33m\]'
BLUE='\[\033[01;34m\]'
PURPLE='\[\033[01;35m\]'
CYAN='\[\033[01;36m\]'
WHITE='\[\033[01;37m\]'
NIL='\[\033[00m\]'
# Hostname styles
FULL='\H'
SHORT='\h'
# System => color/hostname map:
# HC: hostname color
# LC: location/cwd color
# HD: hostname display (\h vs \H)
# UC: username colour
# Defaults:
HC=$YELLOW
LC=$BLUE
HD=mac
UC=$GREEN
# Manually cut hostname; hostname -s bails out on some systems.
case $( hostname | cut -d '.' -f 1 ) in
# yonah | yonah-nix | diamondville ) HC=$YELLOW LC=$GREEN HD=$SHORT ;;
*-production ) HC=$RED HD=$SHORT ;;
mail | code | www* | monitor | xen | penryn ) HC=$RED ;;
esac
# Highlight when we're a special user
case ${USERNAME} in
root | www-data ) UC=$RED ;;
esac
# Prompt function because PROMPT_COMMAND is awesome
function set_prompt() {
# If logged in as another user, not gonna have all this firing anyway.
# So let's just show the host only and be done with it.
host="${HC}${HD}${NIL}"
# Virtualenv
_venv=`basename "$VIRTUAL_ENV"`
venv="" # need this to clear it when we leave a venv
if [[ -n $_venv ]]; then
venv=" ${NIL}{${PURPLE}${_venv}${NIL}}"
fi
# Dollar/hash
end="${LC}\$ ${NIL}"
# Working dir
wd="${LC}\w"
# bzr version
if [[ -f .bzr/branch/last-revision ]];
then
BZRVER=`cat .bzr/branch/last-revision| awk '{print $1}'`
BZR=" ${RED}{bzr rev: ${BZRVER}}${NIL}"
else
BZR=""
fi
# svn version
if [[ -f .svn/entries ]];
then
SVNVER=`svn info | grep Revision | awk '{print $NF}'`
SVN=" ${RED}{svn rev: ${SVNVER}}${NIL}"
else
SVN=""
fi
# Feels kind of like cheating...but works so well!
export PS1="${host}:${wd}${venv}${BZR}${SVN} ${UC}\u${end}"
}
export PROMPT_COMMAND=set_prompt
# Dont store commands starting with a space in the history
export HISTIGNORE="[ ]*"
alias ls="ls -F"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment