railstips.org
06 Aug '12, 10pm
love a nice terminal
I have seen this around and this morning finally decided to try it out. Thus far I am finding it surprisingly helpful. If you put the following in your bash profile, it will show the current git branch in your terminal prompt. bash profile addition function parse_git_branch { ref=$(git-symbolic-ref HEAD 2> /dev/null) || return echo "("${ref#refs/heads/}")" } PS1="\w \$(parse_git_branch)\$ " If you are not in a directory that is a git repository it will just provide a normal prompt but if you are in a directory with a git repo, you’ll get a prompt like the following, even when you switch branches: ~/dev/projects/httparty (master)$ gb integration * master ~/dev/projects/httparty (master)$ git co integration Switched to branch "integration" ~/dev/projects/httparty (integration)$ Pretty handy, eh? I actually bedazzled mine a bit more with color and the current time like this: ...
Full article:
http://railstips.org/blog/archives/2009/02/02/bedazzle-yo...