在 Mac Bash 中显示 git 分支和状态
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16536512/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Show git branch and status in Mac Bash
提问by Dozer
I use the Github for windows client.The shell with powershell is very nice!
我使用 Github for windows 客户端。带有 powershell 的 shell 非常好!


How do I implement it on MAC?
Not only the branch name,I also want git status
我如何在 MAC 上实现它?不光是分店名,我也想要git status
采纳答案by Dozer
回答by djromero
Git itself has this: https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh
Git 本身有这个: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.
绿色名称是分支,右括号前的符号是状态。

