Thursday, August 2, 2012

Defining a bash prompt similar to:
PS1="\u@\h\ [\$(git branch 2>/dev/null | grep ^\* | sed 's/\*/branch:/')]:\w\$ "
(where the blue text is the added extension to the existing Prompt -PS1 variable-) will automatically show on the prompt the active branch we are working on. Ex.:
earizon@desktop[branch: master]:~/myGitRepo$ git branch
* master
  branch1
  branch2
  branch3
earizon@desktop[branch: master]:~/myGitRepo$ git checkout branch2
Switched to branch 'branch2'
earizon@desktop[branch: branch2]:~/myGitRepo$ cd .. # <- exit git repo directory
earizon@desktop[]:~$ 

No comments: