Quantcast
Channel: Unix/Linux
Viewing all articles
Browse latest Browse all 14

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

$
0
0
Wiki Terms: 

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)$


Viewing all articles
Browse latest Browse all 14

Trending Articles