2013-05-14 150 views

回答

5

vcprompt提供类似的shell提示Git(和Hg,Bazaar和SVN)。您可以通过homebrew安装:

brew install vcprompt 
24

的Git本身具有这样的:https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh

用法示例:

GIT_PS1_SHOWUPSTREAM="auto" 
GIT_PS1_SHOWCOLORHINTS="yes" 
source ~/.git-prompt.sh 

export PROMPT_COMMAND='__git_ps1 "\[email protected]\h:\W" "\\\$ ";' 

它看起来像这样:

enter image description here

绿色名称是分支,符号l在右括号之前是状态。

+2

你需要把djromero的使用样品到〜/ .bash_profile中。默认情况下,你可能不会在Mac上有一个,所以你需要创建该文件,然后使用上面的逐字记录(假设git-prompt.sh保存在〜/ .git-prompt.sh中)。 – 2014-03-13 21:37:20