You’ve installed the version of git-completion.bash
from master
– in git’s development history this is after a commit that split out the __git_ps1
function from the completion functionality into a new file (git-prompt.sh
). The commit that introduced this change, which explains the rationale, is af31a456.
I would still suggest that you just source the version of git-completion.bash
(or git-prompt.sh
) that is bundled with your installation of git.
However, if for some reason you still want to use this functionality by using scripts separately downloaded from master
, you should download git-prompt.sh
similarly:
curl -o ~/.git-prompt.sh \
https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
… and add the following line to your ~/.bash_profile
:
source ~/.git-prompt.sh
Then your PS1
variable that includes __git_ps1 '%s'
should work fine.
Geoff reported 10/13/12 adding the following to their .bash_profile
worked while others did not:
if [ -f ~/.git-prompt.sh ]; then
source ~/.git-prompt.sh
export PS1='Geoff[\W]$(__git_ps1 "(%s)"): '
fi