(Mac) -bash: __git_ps1: command not found
After upgrading to OSX 10.9 Mavericks I had to reference the following files to get git shell command completion and git prompt to work again.
From my .bash_profile or similar:
if [ -f /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-completion.bash ]; then
. /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-completion.bash
fi
source /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-prompt.sh
#shell prompt example
PS1='\u $(__git_ps1 "(%s)")\$ '
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.