(Mac) -bash: __git_ps1: command not found

后端 未结 19 2059
感动是毒
感动是毒 2020-11-30 16:20

I\'m trying to change my command promt in terminal. I keep getting the error:

-bash: __git_ps1: command not found

I\'ve tried it just by typing

19条回答
  •  情书的邮戳
    2020-11-30 17:11

    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.

提交回复
热议问题