(Mac) -bash: __git_ps1: command not found

后端 未结 19 1999
感动是毒
感动是毒 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:00

    This one worked for me, and it has colored git output and an indicator in the prompt whether files have changed / been added, right baked into it:

    GIT_PS1_SHOWDIRTYSTATE=true
    
    . /usr/local/Cellar/git/1.8.5.2/etc/bash_completion.d/git-completion.bash
    . /usr/local/Cellar/git/1.8.5.2/etc/bash_completion.d/git-prompt.sh
    
    PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\$ '
    

    Be sure to use the correct path! I used homebrew to install git, use brew list git to get the path to your current installation.

    Would be nice not to use a hard coded path, but don't know how to get the path to the current installation.

    More infos here: http://en.newinstance.it/2010/05/23/git-autocompletion-and-enhanced-bash-prompt/

提交回复
热议问题