Today I updated mac ports and a new error started to show up at the command line saying that the __git_ps1 command is not found.
This is because I added the git branch in my bash prompt long time back and in last update of git-core port they moved the __git_ps1 bash functions to a separate script.

To fix it, you just need to include following lines in your .profile (or .bashrc):

if [ -f /opt/local/share/doc/git-core/contrib/completion/git-prompt.sh ]; then
    . /opt/local/share/doc/git-core/contrib/completion/git-prompt.sh
fi

It worked for me.

Depending on your git installation, this file may be located elsewhere; find command should help in this case.

Update 30-03-2013:

They changed the location of those files again. Super!

now they are here:

/opt/local/share/git-core/contrib/completion/git-completion.bash
/opt/local//share/git-core/contrib/completion/git-prompt.sh

just include them.
Hope they won’t change the paths again soon :)


7 Responses to “-bash: __git_ps1: command not found”  

  1. 1 Chris

    I had this problem aswell. Thanks for the tip, it worked for me.

    I was just wondering, how did you figure out that they moved the __git_ps1 bash functions?

  2. 2 Luigi

    Chris, I don’t remember exactly. At first I checked if set contained the __git_ps1 function, using grep and less, then I checked if they moved the git-completion.bash somewhere else, using find, but it was still at the same place as before. Then I searched around to find __git_ps1 function and it was easy since in the directory /opt/local/share/doc/git-core/contrib/completion there were just two files: git-completion.bash and git-prompt.sh.

  3. 3 Talha

    Thanks Luigi. It was super helpful. My bash prompt broke down after my recent update of git installation.

  4. 4 David

    thanks for the tip, my .profile now looks like this:

    # Set git autocompletion and PS1 integration
    GIT_COMPLETION_FILE='/opt/local/share/doc/git-core/contrib/completion/git-completion.bash';
    GIT_PROMPT_FILE='/opt/local/share/doc/git-core/contrib/completion/git-prompt.sh'
    if [ -f $GIT_COMPLETION_FILE ]; then
    . $GIT_COMPLETION_FILE
    fi
    if [ -f $GIT_PROMPT_FILE ]; then
    . $GIT_PROMPT_FILE
    fi
    GIT_PS1_SHOWDIRTYSTATE=true
    PS1='\[33[32m\]\u@\h\[33[00m\]:\[33[36m\]\w\[33[31m\]$(__git_ps1)\[33[00m\]\$ '

  5. 5 Luigi

    They changed the location of those files again. Super!

    now they are here:

     /opt/local/share/git-core/contrib/completion/git-completion.bash
     /opt/local//share/git-core/contrib/completion/git-prompt.sh
    
  6. 6 Jeffery Fernandez

    freaking hell, why do they keep changing this all the time. Thanks for the update :)

  1. 1 JK | Setting up Git on OSX


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



Calendar

September 2012
M T W T F S S
« Jul   Nov »
 12
3456789
10111213141516
17181920212223
24252627282930

Follow me

twitter flickr LinkedIn feed

Subscribe by email

Enter your email address:

Archives


Categories

Tag Cloud


Listening