|Keywords:||bash git ps1|
Add the following line somewhere before your PS1="..." entry in your .bash_profile file:
Then, in your PS1="..." entry, add the following in the location you want the additional GIT info to appear:
PS1="\h \w \$(git_ps1_info) $ "
will create a prompt looking something like this:
mymachinename ~/code/git_ps1_info (master) $
When you are on a branch the prompt usually looks like this (eg. master):
If you are on an un-named commit, it will show the abbreviated commit message:
And if you are on a merge commmit, it will show you the merge parents as well:
(master < e19faca dbcbc8f)
In addition, if there are any outstanding changes, (not including untracked files), the current branch name will be highlighted in red.