Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: stash count in gitstatus #4685

Closed
sagotsky opened this issue Dec 9, 2015 · 2 comments
Closed

Feature request: stash count in gitstatus #4685

sagotsky opened this issue Dec 9, 2015 · 2 comments

Comments

@sagotsky
Copy link

sagotsky commented Dec 9, 2015

I started making a PR for this, then realized my oh-my-zsh is woefully out of date. Here's a patch instead. It adds a Popen to count git stash list output, exports a variable, and adds that var to the zsh status.

diff --git a/.zsh/plugins/zsh-git-prompt/gitstatus.py b/.zsh/plugins/zsh-git-prompt/gitstatus.py
index 657db46..c3f5ac2 100755
--- a/.zsh/plugins/zsh-git-prompt/gitstatus.py
+++ b/.zsh/plugins/zsh-git-prompt/gitstatus.py
@@ -62,6 +62,8 @@ else:
                if ahead:
                        remote += '%s%s' % (symbols['ahead of'], ahead)

+stashed = str(len(Popen(['git','stash','list'],stdout=PIPE).communicate()[0].split("\n")) - 1)
+
 out = '\n'.join([
        str(branch),
        remote,
@@ -69,6 +71,8 @@ out = '\n'.join([
        conflicts,
        changed,
        untracked,
-       clean])
+       clean,
+        stashed
+        ])
 print(out)

diff --git a/.zsh/plugins/zsh-git-prompt/zshrc.sh b/.zsh/plugins/zsh-git-prompt/zshrc.sh
index 14e68aa..b3feb31 100644
--- a/.zsh/plugins/zsh-git-prompt/zshrc.sh
+++ b/.zsh/plugins/zsh-git-prompt/zshrc.sh
@@ -48,6 +48,7 @@ function update_current_git_vars() {
        GIT_CHANGED=$__CURRENT_GIT_STATUS[5]
        GIT_UNTRACKED=$__CURRENT_GIT_STATUS[6]
        GIT_CLEAN=$__CURRENT_GIT_STATUS[7]
+       GIT_STASHED=$__CURRENT_GIT_STATUS[8]
 }


@@ -74,6 +75,11 @@ git_super_status() {
          if [ "$GIT_CLEAN" -eq "1" ]; then
                  STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CLEAN"
          fi
+
+    if [ "$GIT_STASHED" -ne "0" ]; then
+      STATUS="$STATUS%{${reset_color}%}{$GIT_STASHED}"
+    fi 
+
          STATUS="$STATUS%{${reset_color}%}$ZSH_THEME_GIT_PROMPT_SUFFIX"
          echo "$STATUS"
        fi
@@ -91,7 +97,6 @@ ZSH_THEME_GIT_PROMPT_REMOTE=""
 ZSH_THEME_GIT_PROMPT_UNTRACKED="…"
 ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}✔"

-
 ZSH_THEME_GIT_PROMPT_STAGED="%{$fg[red]%}•"
 ZSH_THEME_GIT_PROMPT_CONFLICTS="%{$fg[red]%}x"
 ZSH_THEME_GIT_PROMPT_CHANGED="%{$fg[blue]%}+"
@mcornella
Copy link
Member

The current version shipped within Oh My Zsh is based off this PR: olivierverdier/zsh-git-prompt#65

@mcornella
Copy link
Member

In any case, feature requests should go directly at https://github.com/olivierverdier/zsh-git-prompt/ before we merge anything. I'd like to converge both versions at some point, so please submit that upstream.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants