Make your bash-prompt git-aware

Today a friend of mine shared a very nice piece of configuration for using git with me.

stevie@box:~/dev/myproject/common [master]$

If you add the following lines into your ~/.bashrc you’ll always know which branch you are on.

Additionally you’ll be informed if the remote branch (if any) has been changed by adding “*” to the branches name. How cool is that?

stevie@box:~/dev/myproject/common [master *]$

Here are the lines to add which will do the magic for you:

1
2
3
4
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
export GIT_PS1_SHOWSTASHSTATE=true
export PS1="${PS1::$((${#PS1}-3))}\$(__git_ps1 ' [\[\e[34;1m\]%s\[\e[0m\]]')\$ "

About stevie

Born in the north of Germany, raised in Berlin and stayed there since. After graduating, studying applied computer science at the FHTW Berlin (now HTW Berlin), I started my own company with a former fellow student, providing high class application solutions for web and desktop for small and medium companies (see www.jnamic.com (english version to be finished) for more information). My personal favorite programming languages are PHP for the web and Java for everything else - although I must admit Java evolved very much in the past few years. I love to code and build new applications from the scratch, optimizing it through day and night till I am satisfied with it's performance. So follow my articles, share your thoughts and experience with me and have a good time browsing this blog!
This entry was posted in common and tagged , , , , . Bookmark the permalink.

Leave a Reply