Thursday, December 13, 2012

git bash prompt in Fedora 18

If you are a git user, chances are your are using a customized bash prompt,
which is usually defined in ~/.bashrc like this:
PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
In case you don't know it, the __git_ps1 is a handy function provided by the git package to show relevant git repository information (branch name, merge status, etc) right at the prompt.

For instance, this is what the prompt looks like when I cd into a git checkout:
[giallu@qbert gittest (master)]$
Today, after updating one of my development boxes to (the not yet released, but we're getting there...) Fedora 18, I started seeing this error in all my terminals:
bash: __git_ps1: command not found
[giallu@qbert ~]$ 
I found that the problem is caused by the move of the __git_ps1 function, from /etc/bash_completion.d/git to /usr/share/git-core/contrib/completion/

So, in order to fix the issue, you just need to edit your bashrc like this:
. /usr/share/git-core/contrib/completion/
PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '

1 comment: