OS X Mavericks:如果存在未提交的更改,Git bash提示已停止跟踪

时间:2013-11-25 13:55:47

标签: macos git bash

我在周末升级到10.9,我的bash提示显示有点时髦。我目前在.bash_profile

中有这个
function parse_git_dirty {
  [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}

PS1="\n\[\e[1;34m\]\$(date +%H:%M) \[\e[1;36m\]\w\[\e[1;33m\] \$(parse_git_branch) \[\e[1;31m\]\$(rvm_version)\n\[\e[0;32m\]> \[\e[0m\]"
unset color_prompt force_color_prompt

以前(在10.8中)产生的提示看起来像这样:

07:45 ~/code/project_dir [git-branch] 1.9.3@project

如果需要将更改提交到我的git分支,则会附加一个星号([git-branch*])。

自升级以来,始终在分支后列出了*。其他一切似乎都正常运作。我怎样才能让它像以前那样表现?

我也已更新到最新版本的git。

2 个答案:

答案 0 :(得分:1)

这似乎是git版本的变化。当我在OS X 10.9(Git 1.8.3.4)中运行git status时,来自干净存储库的消息是

nothing to commit, working directory clean

答案 1 :(得分:0)

根据@chepner,我转而使用git-prompt.sh通过自制程序的bash-completion包。

相关问题