Subversion-aware bash prompts
6Oct2009
This is a handy trick to see whether you're in a directory managed by version control or not.

To enable this prompt, I use the following code snippet (in my .bashrc file):
pimpmyprompt() {
if test -d `pwd`/.svn ; then
pwd | sed -e "s#^$HOME/*# #" -e "s#/.*\$##"
fi
}
export PS1="\u\[\e[0;32m\]\$(pimpmyprompt)\[\e[m\]:\w$ "
Note: This will always print the name of the first path component after $HOME, which is not necessarily a SVN working copy.
Update: Also have a look at Frank's hint in the comments, which looks quite useful for when the customizations start to grow. :-)
Update: Make sure to surround your ANSI color escape sequences with
\[ and \]. This will enable the readline
library to recognize these as non-printed characters and correctly
count your promt's length. Without it, your prompt will occasionally
be garbled.