【问题标题】:Show git branch and status in Mac Bash [duplicate]在 Mac Bash 中显示 git 分支和状态 [重复]
【发布时间】:2013-05-08 08:10:19
【问题描述】:

我用的是 Github for windows 客户端。带有 powershell 的 shell 很不错!

如何在 MAC 上实现它? 不光分店名,我也要git status

【问题讨论】:

    标签: macos git bash


    【解决方案1】:

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

    brew install vcprompt
    

    【讨论】:

      【解决方案2】:

      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 "\u@\h:\W" "\\\$ ";'
      

      看起来像这样:

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

      【讨论】:

      • 您需要将 djromero 的使用示例放入 ~/.bash_profile。默认情况下你可能在 Mac 上没有,所以你需要创建文件,然后逐字使用上述文件(假设 git-prompt.sh 保存在 ~/.git-prompt.sh)。
      【解决方案3】:

      我觉得ohmyzsh是我最好的选择!

      https://github.com/robbyrussell/oh-my-zsh

      【讨论】:

      • oh-my-zsh 非常具有侵入性,仅用于这个 git 好处
      猜你喜欢
      • 1970-01-01
      • 2012-08-29
      • 2012-09-28
      • 2017-10-29
      • 2020-08-26
      • 2020-12-16
      • 2018-07-15
      • 2012-11-07
      • 2022-11-04
      相关资源
      最近更新 更多