From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 903750cb for ; Sat, 21 Dec 2019 21:05:28 +0000 (UTC) Received: (qmail 17297 invoked by alias); 21 Dec 2019 15:59:14 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45116 Received: (qmail 8855 invoked by uid 1010); 21 Dec 2019 15:59:14 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25663. spamassassin: 3.4.2. Clear:RC:0(66.111.4.25):SA:0(-1.9/5.0):. Processed in 3.018833 secs); 21 Dec 2019 15:59:14 -0000 X-Envelope-From: danielsh@apache.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: softfail (ns1.primenet.com.au: transitioning SPF record at amazonses.com does not designate 66.111.4.25 as permitted sender) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvdduhedgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgogfeguddtqddvjeculdegtddmnecujfgurhephf fvufffkffosedttdertdertddtnecuhfhrohhmpeffrghnihgvlhcuufhhrghhrghfuceo uggrnhhivghlshhhsegrphgrtghhvgdrohhrgheqnecukfhppeejledrudektddrheejrd duudelnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurghnihgvlhhshhesrghprggthhgv rdhorhhgnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: From: Daniel Shahaf 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 Message-Id: <20191221155828.25950-1-danielsh@apache.org> X-Mailer: git-send-email 2.11.0 --- 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