WebTechKitchen; Your Web Technology Kitchen, contact us to create, or maintain your websites and other digital properties.

Tip of the Day: have your mac command prompt tell you which git branch you're in

Submitted by barnettech on Fri, 02/22/2013 - 09:50

A colleague just shared this tip with me to have my Mac command prompt tell me which git branch I'm in:  Put the following in your .bash_profile

 

function parse_git_branch () {

  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'

}

 

export PS1="\h:\W \u\$(parse_git_branch)\$ "

Now my command prompt looks like this in a git directory:  belldev2:docroot barnettech (master)$