Home > bash, Interesting > Show current git branch on your bash prompt

Show current git branch on your bash prompt

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 https://github.com/git/git/raw/master/contrib/completion/git-completion.bash -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


  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: