How to Display your Local Git Branch in your BASH prompt

In order to make your life easier when working with git, this article provides the steps to display the current local git branch within your bash prompt. This not only saves you time, but also prevents the potential for human error by ensuring you are not making changes to the wrong branch.

Download Script

First all we download the git prompt script.

curl -o ~/

Update .Bashrc

We then add the following lines to ~/.bashrc

# import script
source ~/

# customize/colorize prompt
export PS1="\e[37m\t\e[37m-\e[97m\u\e[92m\e[92m\w\[\033[m\]\e[96m\$(__git_ps1)\e[97m\$ "



Tags: Github, BASH, Git

About the Author


R Donato

Rick Donato is the Founder and Chief Editor of He currently works as a Principal Network Security Engineer and has a keen interest in automation and the cloud.

You can find Rick on Twitter @f3lix001