From c09b59d96a778769325280f6185a73dc984edcad Mon Sep 17 00:00:00 2001 From: Ali B Date: Sun, 7 Aug 2011 13:53:23 +1000 Subject: [PATCH 1/2] Add variables that can be used to wrap the git status prompt. Also return if working copy is clean. --- lib/git.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index f04343650..c2b490c04 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -32,8 +32,8 @@ function git_prompt_long_sha() { # Get the status of the working tree git_prompt_status() { - INDEX=$(git status --porcelain 2> /dev/null) - STATUS="" + INDEX=$(git status --porcelain 2> /dev/null) || return + STATUS="$ZSH_THEME_GIT_STATUS_AFTER" if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" fi @@ -60,5 +60,5 @@ git_prompt_status() { if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" fi - echo $STATUS + echo "$ZSH_THEME_GIT_STATUS_BEFORE$STATUS" } From cf05e182ea15c1a275db8149379798b2ed652f62 Mon Sep 17 00:00:00 2001 From: Ali B Date: Mon, 8 Aug 2011 23:47:30 +1000 Subject: [PATCH 2/2] Only wrap $STATUS when not empty. --- lib/git.zsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index c2b490c04..26aad353e 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -33,7 +33,7 @@ function git_prompt_long_sha() { # Get the status of the working tree git_prompt_status() { INDEX=$(git status --porcelain 2> /dev/null) || return - STATUS="$ZSH_THEME_GIT_STATUS_AFTER" + STATUS="" if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" fi @@ -60,5 +60,7 @@ git_prompt_status() { if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" fi - echo "$ZSH_THEME_GIT_STATUS_BEFORE$STATUS" + if [[ "$STATUS" != "" ]]; then + echo "$ZSH_THEME_GIT_STATUS_BEFORE$STATUS$ZSH_THEME_GIT_STATUS_AFTER" + fi }