Git and GitHub is one of the most imortant tool for software development.
One of its great feature is branching/merging. Whenever I am inside a git directory, I have to run git status
to see which branch I am currently working on. Contstantly switching branches is always confusing to me.
The solution to this is to have the terminal prompt display the current branch name.
Installation
First create a .bash
directory in your home directory and clone the project to it:
$ mkdir ~/.bash
$ cd ~/.bash
$ git clone https://github.com/jimeh/git-aware-prompt.git
Edit your ~/.bashrc
and add the following to the bottom:
export GITAWAREPROMPT=~/.bash/git-aware-prompt
source "${GITAWAREPROMPT}/main.sh"
export PS1="\${debian_chroot:+(\$debian_chroot)}\u@\h:\w \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "
Now cd
into any git directory, current branch name will be shown in the terminal prompt.