Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: vcs_info-examples: untracked hook for git



Signed-off-by: Valentin Haenel <valentin.haenel@xxxxxx>
---
 Misc/vcs_info-examples |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/Misc/vcs_info-examples b/Misc/vcs_info-examples
index bc10a21..860297c 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
 
-- 
1.7.1



Messages sorted by: Reverse Date, Date, Thread, Author