{"id":1019,"date":"2016-08-08T12:17:56","date_gmt":"2016-08-08T12:17:56","guid":{"rendered":"https:\/\/fir3netwp.gmsrrpobkbd.com\/2016\/08\/08\/how-to-display-your-local-git-branch-in-your-bash-prompt\/"},"modified":"2021-07-24T15:14:41","modified_gmt":"2021-07-24T15:14:41","slug":"how-to-display-your-local-git-branch-in-your-bash-prompt","status":"publish","type":"post","link":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-display-your-local-git-branch-in-your-bash-prompt.html","title":{"rendered":"How to Display your Local Git Branch in your BASH prompt"},"content":{"rendered":"
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.<\/p>\n
First all we download the git prompt script.<\/p>\n
curl https:\/\/raw.githubusercontent.com\/git\/git\/master\/contrib\/completion\/git-prompt.sh -o ~\/.git-prompt.sh<\/pre>\nUpdate .Bashrc<\/h2>\n
We then add the following lines to ~\/.bashrc<\/span>. <\/p>\n
# import script
source ~\/.git-prompt.sh
# 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\\$ \"<\/pre>\nExample<\/h2>\n