Ubuntu: Show current Git branch on Terminal prompt

There are times when I keep running git status or git branch to check which branch I’m on and I just found that I could do something to show the name of my current Git branch on my Terminal prompt, thanks to a colleague.

In the following screenshot I’m working in the directory “sample_app”, on Git branch that is named “static-pages”:


In Ubuntu, here’s how I did it.

Create .bash directory in Home:
mkdir ~/.bash

Go to the new directory
cd ~/.bash

Clone the git-aware project from GitHub:
git clone git://github.com/jimeh/git-aware-prompt.git

Edit your .bashrc file. I use Vim editor for this:
vim ~/.bashrc

Add the following to the top of your .bashrc:

If you want colored prompts, add the following to the bottom of your .bashrc:

Otherwise, if you doon’t like colors, use this instead:

Open a new Terminal tab or restart Terminal. Navigate to any directory that has a Git repository and your Ubuntu’s Terminal prompt should now show the current Git branch’s name.

Related Posts:

Posts that may be related to "Ubuntu: Show current Git branch on Terminal prompt":


A Filipino programmer with a variety of interests such as baking, singing, making up silly song/rap lyrics, K-pop, drawing, creating unique dessert flavors, obsessing about finding out how some things works, board games, anime, video games, and forgetting things that usually go in her long list of interests. Running small-time online dessert shops Cookies PH and Catzie's Cakery.

Leave a Reply

Your email address will not be published. Required fields are marked *