From: Daniel Shahaf <danielsh@apache.org>
To: zsh-workers@zsh.org
Subject: [PATCH 1/5] vcs_info examples: Add an example of showing Git environment variables.
Date: Sat, 21 Dec 2019 15:58:24 +0000 [thread overview]
Message-ID: <20191221155828.25950-1-danielsh@apache.org> (raw)
---
Misc/vcs_info-examples | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/Misc/vcs_info-examples b/Misc/vcs_info-examples
index c46fad93a..028fe62b0 100644
--- a/Misc/vcs_info-examples
+++ b/Misc/vcs_info-examples
@@ -222,6 +222,31 @@ zstyle -e ':vcs_info:git+set-message:*' hooks 'reply=( ${${(k)functions[(I)[+]vi
# Both of these functions would be called, even if they are defined after the zstyle is set.
+## git: Display pertinent environment variables
+# If environment variables such as $GIT_DIR, $GIT_WORK_TREE, etc are set in the
+# environment, they'll be shown in the value of the %m expando.
+#
+# Note that the %m expando is not used by default. To see a change, either change
+# `[misc]' to `[branch]', or set the `formats` style to a value that includes `%m'.
+zstyle ':vcs_info:git+post-backend:*' hooks git-post-backend-envvars
++vi-git-post-backend-envvars() {
+ local param
+ # This uses the ${parameters} special variable (provided by the zsh/parameter
+ # module), in conjunction with the parameter expansion flags ${(k)foo} and
+ # ${(M)foo:#pattern} (documented in "Parameter Expansion" in zshexpn(1))
+ # and the (R) subscript flag (documented in "Subscript Flags" in zshparam(1)),
+ # to iterate over the names of all environment variables named "GIT_*". Then
+ # it uses the ${(P)foo} parameter expansion flag to show the values of those
+ # parameters.
+ #
+ # The value of ${hook_com[misc]} is substituted for %m in the values of the
+ # 'formats' and 'actionformats' styles.
+ for param in ${(Mk)parameters[(R)*export*]:#GIT_*}; do
+ hook_com[misc]+=";%U${param//'%'/%%}%u=%F{white}${${(P)param}//'%'/%%}%f"
+ done
+}
+
+
### hg: Show marker when the working directory is not on a branch head
# This may indicate that running `hg up` will do something
# NOTE: the branchheads.cache file is not updated with every Mercurial
next reply other threads:[~2019-12-21 21:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-21 15:58 Daniel Shahaf [this message]
2019-12-21 15:58 ` [PATCH 2/5] vcs_info examples: Make the quilt-patch-dir example friendlier Daniel Shahaf
2019-12-21 15:58 ` [PATCH 3/5] vcs_info quilt: Improve support for svn-style patch headers Daniel Shahaf
2019-12-21 15:58 ` [PATCH 4/5] vcs_info docs: Clarify documentation of the %p/%u/%a patch-format expandos Daniel Shahaf
2019-12-21 15:58 ` [PATCH 5/5] zshmodules: Explicitly document the return values of the 'zstyle' getters -s, -b, and -a Daniel Shahaf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191221155828.25950-1-danielsh@apache.org \
--to=danielsh@apache.org \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).