Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 在macbash中显示git分支和状态_Macos_Git_Bash - Fatal编程技术网

Macos 在macbash中显示git分支和状态

Macos 在macbash中显示git分支和状态,macos,git,bash,Macos,Git,Bash,我使用Github for windows客户端。带powershell的shell非常好 如何在MAC上实现它? 不仅是分支名称,我还希望git status为git(以及Hg、Bazaar和SVN)提供类似的shell提示。您可以通过以下方式进行安装: Git本身有以下特点: 使用示例: GIT_PS1_SHOWUPSTREAM="auto" GIT_PS1_SHOWCOLORHINTS="yes" source ~/.git-prompt.sh export PROMPT_COMMAN

我使用Github for windows客户端。带powershell的shell非常好

如何在MAC上实现它? 不仅是分支名称,我还希望
git status

为git(以及Hg、Bazaar和SVN)提供类似的shell提示。您可以通过以下方式进行安装:

Git本身有以下特点:

使用示例:

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

export PROMPT_COMMAND='__git_ps1 "\u@\h:\W" "\\\$ ";'
看起来是这样的:


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

我认为ohmyzsh是我的最佳选择


您需要将djromero的使用示例放入~/.bash_配置文件中。默认情况下,您在Mac上可能不会有一个,因此您需要创建文件,然后使用上面的逐字记录(假设git-prompt.sh保存在~/.git prompt.sh)
GIT_PS1_SHOWUPSTREAM="auto"
GIT_PS1_SHOWCOLORHINTS="yes"
source ~/.git-prompt.sh

export PROMPT_COMMAND='__git_ps1 "\u@\h:\W" "\\\$ ";'