(Mac) -bash: __git_ps1: command not found

后端 未结 19 2056
感动是毒
感动是毒 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 16:48

    I was doing the course on Udacity for git hub and was having this same issue. Here is my final code that make is work correctly.

    # Change command prompt
    alias __git_ps1="git branch 2>/dev/null | grep '*' | sed 's/* \ .   (.*\)/(\1)/'"
    
    if [ -f ~/.git-completion.bash ]; then
      source ~/.git-completion.bash
      export PS1='[\W]$(__git_ps1 "(%s)"): '
    fi
    
    source ~/.git-prompt.sh
    export GIT_PS1_SHOWDIRTYSTATE=1
    # '\u' adds the name of the current user to the prompt
    # '\$(__git_ps1)' adds git-related stuff
    # '\W' adds the name of the current directory
    export PS1="$purple\u$green\$(__git_ps1)$blue \W $ $reset"
    

    It works! https://i.stack.imgur.com/d0lvb.jpg

提交回复
热议问题