+ # Display number of WIP stashes (this excludes manually named commits
+ # which might be used for something else), thanks to
+ # http://eseth.org/2010/git-in-zsh.html (viewed on 2013-04-27) for the
+ # idea to display the stash count.
+ function +vi-git-stashes() {
+ if [[ -s ${hook_com[base]/.git/refs/stash} ]]; then
+ local -a stashes
+ # Thanks to Valodim in #zsh on Freenode (2013-07-01 14:14 CEST)
+ # for the solution to "grep" the output with (M) and :#(...).
+ stashes=${#${(M)${(f)"$(git stash list 2>/dev/null)"}:#(*WIP*)}}
+
+ if [[ $stashes -gt 0 ]]; then
+ hook_com[misc]+=" ${yellow}${stashes}s${default}"
+ fi
+ fi
+ }
+
+ # Apply hooks to Git.
+ zstyle ':vcs_info:git*+set-message:*' hooks git-stashes
+