]> ruderich.org/simon Gitweb - config/dotfiles.git/commitdiff
zsh/rc: Only use %u/%c if VCS_Info is current enough.
authorSimon Ruderich <simon@ruderich.org>
Thu, 11 Mar 2010 15:28:10 +0000 (16:28 +0100)
committerSimon Ruderich <simon@ruderich.org>
Thu, 11 Mar 2010 15:28:10 +0000 (16:28 +0100)
This prevents a display problem in older versions.

zsh/rc

diff --git a/zsh/rc b/zsh/rc
index caa9c5f2f28e78f42ed2690467264ca1695aff94..487c4bc1bf5d103a7275a4fd2254dbe02c0a62ca 100644 (file)
--- a/zsh/rc
+++ b/zsh/rc
@@ -168,10 +168,20 @@ if [[ $ZSH_VERSION == (4.3.<9->|4.<4->*|<5->*) ||
     # is displayed. If there is an special action going on (merge, rebase)
     # it's also displayed (red). Also display if there are unstaged or staged
     # (%u/%c) changes.
-    zstyle ':vcs_info:*' formats \
-        "($green%b%u%c$default:$blue%s$default)"
-    zstyle ':vcs_info:*' actionformats \
-        "($green%b%u%c$default/$red%a$default:$blue%s$default)"
+    if [[ $ZSH_VERSION == (4.3.<11->|4.<4->*|<5->*) ||
+          -d ~/.zsh/functions/vcs_info ]]; then
+        zstyle ':vcs_info:*' formats \
+            "($green%b%u%c$default:$blue%s$default)"
+        zstyle ':vcs_info:*' actionformats \
+            "($green%b%u%c$default/$red%a$default:$blue%s$default)"
+    else
+        # In older versions %u and %c are not defined yet and are not
+        # correctly expanded.
+        zstyle ':vcs_info:*' formats \
+            "($green%b$default:$blue%s$default)"
+        zstyle ':vcs_info:*' actionformats \
+            "($green%b$default/$red%a$default:$blue%s$default)"
+    fi
     # Set style for formats/actionformats when unstaged (%u) and staged (%c)
     # changes are detected in the repository; check-for-changes must be set to
     # true for this to work. Thanks to Bart Trojanowski