Posts Tagged ‘git dirty state’

Show current git branch on your bash prompt

September 8, 2015 Leave a comment

I started learning to use git and the examples I saw showed the branches on the command prompt which I think is very cool and helpful. And of course, I wanted that too.

In 3 simple steps.

1. Download
curl -OL
2. Add the following to .bashrc

# Add Git configurations
source git-completion.bash
export PS1='\[\033[1;34m\]\!\[\033[0m\] \[\033[1;35m\]\u\[\033[0m\]:\[\033[1;35m\]\W\[\033[0m\] \[\033[1;92m\]$(__git_ps1 "(%s)")\[\033[0m\]\$ '

3. Restart your terminal so that the changes take place or source your bashrc YMMV.

This is just the tip of the iceberg. You can get much much more at the resources listed below