summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrank Terbeck <bewater@users.sourceforge.net>2011-06-01 21:21:04 +0000
committerFrank Terbeck <bewater@users.sourceforge.net>2011-06-01 21:21:04 +0000
commit0deff4f99aaf2e6389ab441eec04c68a9a27681d (patch)
treeb004f9ee6534da765b77dfde81e0069bf91cd696
parent0cc65dba531a792db26592a4e9c1efe5f9f667bd (diff)
downloadzsh-0deff4f99aaf2e6389ab441eec04c68a9a27681d.tar.gz
zsh-0deff4f99aaf2e6389ab441eec04c68a9a27681d.tar.xz
zsh-0deff4f99aaf2e6389ab441eec04c68a9a27681d.zip
Valentin Haenel: 29431: Hook example for signaling untracked files in git repositories
-rw-r--r--ChangeLog7
-rw-r--r--Misc/vcs_info-examples17
2 files changed, 23 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index eb64cd4cc..9c5b99de6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-06-01  Frank Terbeck  <ft@bewatermyfriend.org>
+
+	* Valentin Haenel: 29431: Misc/vcs_info-examples: Hook example for
+	signaling untracked files in git repositories.
+
 2011-06-01  Barton E. Schaefer  <schaefer@zsh.org>
 
 	* users/16064: Functions/Zle/move-line-in-buffer: example widget
@@ -14912,5 +14917,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5352 $
+* $Revision: 1.5353 $
 *****************************************************
diff --git a/Misc/vcs_info-examples b/Misc/vcs_info-examples
index bc10a2179..860297c9e 100644
--- a/Misc/vcs_info-examples
+++ b/Misc/vcs_info-examples
@@ -155,6 +155,23 @@ function +vi-hg-shorthash() {
     ret=1
 }
 
+### Display the existence of files not yet known to VCS
+
+### git: Show marker (T) if there are untracked files in repository
+# Make sure you have added staged to your 'formats':  %c
+zstyle ':vcs_info:git*+set-message:*' hooks git-untracked
+
++vi-git-untracked(){
+    if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \
+        git status --porcelain | grep '??' &> /dev/null ; then
+        # This will show the marker if there are any untracked files in repo.
+        # If instead you want to show the marker only if there are untracked
+        # files in $PWD, use:
+        #[[ -n $(git ls-files --others --exclude-standard) ]] ; then
+        hook_com[staged]+='T'
+    fi
+}
+
 
 ### Compare local changes to remote changes