From a0275f5ab5e4fa37ecc458f0b9e27a5b93ea17de Mon Sep 17 00:00:00 2001 From: Wesley Moore Date: Thu, 1 Apr 2010 09:11:25 +1100 Subject: [PATCH] Improve the git prompt. Conflicts: themes/prose.zsh-theme --- lib/git.zsh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index 629a08b0e..a34140d89 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -5,10 +5,18 @@ function git_prompt_info() { } parse_git_dirty () { - if [[ $((git status 2> /dev/null) | tail -n1) != "nothing to commit (working directory clean)" ]]; then - echo "$ZSH_THEME_GIT_PROMPT_DIRTY" - else - echo "$ZSH_THEME_GIT_PROMPT_CLEAN" + gitstat=$(git status 2>/dev/null | grep '\(# Untracked\|# Changes\|# Changed but not updated:\)') + + if [[ $(echo ${gitstat} | grep -c "^# Changes to be committed:$") > 0 ]]; then + echo -n "$ZSH_THEME_GIT_PROMPT_DIRTY" + fi + + if [[ $(echo ${gitstat} | grep -c "^\(# Untracked files:\|# Changed but not updated:\)$") > 0 ]]; then + echo -n "$ZSH_THEME_GIT_PROMPT_UNTRACKED" + fi + + if [[ $(echo ${gitstat} | wc -l | tr -d ' ') == 0 ]]; then + echo -n "$ZSH_THEME_GIT_PROMPT_CLEAN" fi }