Skip to content
This repository

Two more variables to wrap the git status prompt #530

Closed
wants to merge 3 commits into from

1 participant

Ali B.
Ali B.

$ZSH_THEME_GIT_STATUS_BEFORE and $ZSH_THEME_GIT_STATUS_AFTER can be used to insert text before and after the git status respectively. An example would be to wrap the status with brackets to get something like foo@~/bar/ (master [+*!])$. I'm currently working on a theme that takes advantage of this so having this merged back to origin would make my life much easier :-)

Ali B. dmondark closed this December 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 4 additions and 2 deletions. Show diff stats Hide diff stats

  1. 6  lib/git.zsh
6  lib/git.zsh
@@ -32,7 +32,7 @@ function git_prompt_long_sha() {
32 32
 
33 33
 # Get the status of the working tree
34 34
 git_prompt_status() {
35  
-  INDEX=$(git status --porcelain 2> /dev/null)
  35
+  INDEX=$(git status --porcelain 2> /dev/null) || return
36 36
   STATUS=""
37 37
   if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then
38 38
     STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
@@ -60,5 +60,7 @@ git_prompt_status() {
60 60
   if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
61 61
     STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
62 62
   fi
63  
-  echo $STATUS
  63
+  if [[ "$STATUS" != "" ]]; then
  64
+    echo "$ZSH_THEME_GIT_STATUS_BEFORE$STATUS$ZSH_THEME_GIT_STATUS_AFTER"
  65
+  fi
64 66
 }
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.