2013-05-14 153 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