Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Danny

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

GIT branch in your bash prompt

To see the currently active (git) branch on your bash prompt whenever you enter a git repository add this to your prompt defenition:

$(git branch &>/dev/null; if [ $? -eq 0 ]; then echo " ($(git branch | grep '^* ' |sed s/\*\ //))"; fi)

Example of my prompt
PS1='\w$(git branch &>/dev/null; if [ $? -eq 0 ]; then echo "($(git branch | grep '^*' |sed s/\*\ //))"; fi)\$ '
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS