Skip to content

Instantly share code, notes, and snippets.

@cztchoice
cztchoice / .bashrc
Created November 3, 2012 14:39 — forked from justintv/.bashrc
Display git branch in bash prompt
# If you work with git, you've probably had that nagging sensation of not knowing what branch you are on. Worry no longer!
#export PS1="\\w:\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)\$ "
# This is easy
export PS1="\w\$(__git_ps1 '(%s)') \$ "
# This will change your prompt to display not only your working directory but also your current git branch, if you have one. Pretty nifty!
# ~/code/web:beta_directory$ git checkout master
# Switched to branch "master"