Add better git support to your bash shell

Add this to your ~/.bash_rc

if [ -f /usr/lib/git-core/git-sh-prompt ]
  source /usr/lib/git-core/git-sh-prompt
  export PS1='[\u@\h\w$(__git_ps1 " (%s)")]\$ '

Then watch your shell go from this


to this

[jim@galago~/projects/HIIT (add-docker)]$

Notice the branch name (add-docker) in the prompt?

You’ll also have command completion for git commands (i.e. git a<tab><tab> will show)

[jim@galago~/projects/HIIT (add-docker)]$ git a
add        am         annotate   apply      archive

And you’ll have command completion for the branches et al (i.e. git checkout <tab><tab> will show)


[jim@galago~/projects/HIIT (add-docker)]$ git checkout 
add-docker          HEAD                ORIG_HEAD           origin/HEAD         reactify 
FETCH_HEAD          master              origin/add-docker   origin/master