I use the Github for windows client.The shell with powershell is very nice!
How do I implement it on MAC?
Not only the branch name,I also want git status
the command prompt will start with username@host and a space ( \u@\h ), in default terminal color (normally, white text on black background). Then comes \[\e[32m\]\w — current working directory ( \w ) in green ( [32m ) color, and a space.
It's /etc/git-prompt.sh that defines the __git_ps1 function (Line #273 in my version) is defined. You'll notice that the __git_ps1 function pulls in several other functions defined in /etc/git-prompt.sh .
Git itself has this: https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh
Usage sample:
GIT_PS1_SHOWUPSTREAM="auto"
GIT_PS1_SHOWCOLORHINTS="yes"
source ~/.git-prompt.sh
export PROMPT_COMMAND='__git_ps1 "\u@\h:\W" "\\\$ ";'
It looks like this:
The green name is the branch, the symbol before the closing parenthesis is the status.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With