Browse Source

Fix logic of bureau_git_status function

This separates the gathering of file status, repository status and
stash.
Marc Cornellà 9 years ago
parent
commit
e1b04cfecd
1 changed files with 21 additions and 15 deletions
  1. 21 15
      themes/bureau.zsh-theme

+ 21 - 15
themes/bureau.zsh-theme

@@ -22,10 +22,12 @@ bureau_git_branch () {
   echo "${ref#refs/heads/}"
   echo "${ref#refs/heads/}"
 }
 }
 
 
-bureau_git_status () {
+bureau_git_status() {
   _STATUS=""
   _STATUS=""
-  if [[ $(command git status --short 2> /dev/null) != "" ]]; then
-    _INDEX=$(command git status --porcelain -b 2> /dev/null)
+
+  # check status of files
+  _INDEX=$(command git status --porcelain 2> /dev/null)
+  if [[ -n "$_INDEX" ]]; then
     if $(echo "$_INDEX" | command grep '^[AMRD]. ' &> /dev/null); then
     if $(echo "$_INDEX" | command grep '^[AMRD]. ' &> /dev/null); then
       _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
       _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
     fi
     fi
@@ -38,22 +40,26 @@ bureau_git_status () {
     if $(echo "$_INDEX" | command grep '^UU ' &> /dev/null); then
     if $(echo "$_INDEX" | command grep '^UU ' &> /dev/null); then
       _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
       _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
     fi
     fi
-    if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then
-      _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STASHED"
-    fi
-    if $(echo "$_INDEX" | command grep '^## .*ahead' &> /dev/null); then
-      _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_AHEAD"
-    fi
-    if $(echo "$_INDEX" | command grep '^## .*behind' &> /dev/null); then
-      _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_BEHIND"
-    fi
-    if $(echo "$_INDEX" | command grep '^## .*diverged' &> /dev/null); then
-      _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_DIVERGED"
-    fi
   else
   else
     _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_CLEAN"
     _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_CLEAN"
   fi
   fi
 
 
+  # check status of local repository
+  _INDEX=$(command git status --porcelain -b 2> /dev/null)
+  if $(echo "$_INDEX" | command grep '^## .*ahead' &> /dev/null); then
+    _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_AHEAD"
+  fi
+  if $(echo "$_INDEX" | command grep '^## .*behind' &> /dev/null); then
+    _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_BEHIND"
+  fi
+  if $(echo "$_INDEX" | command grep '^## .*diverged' &> /dev/null); then
+    _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_DIVERGED"
+  fi
+
+  if $(command git rev-parse --verify refs/stash &> /dev/null); then
+    _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STASHED"
+  fi
+
   echo $_STATUS
   echo $_STATUS
 }
 }