From 0057f30bf04f8d0f5e855846805ca261a3c6c4a7 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 14 Apr 2021 14:49:13 +0000 Subject: [PATCH 5/8] vcs_info docs: Recommend use of prompt expandos rather than terminal escape sequences. --- Doc/Zsh/contrib.yo | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 5e91f9a8d..07bf4e054 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -1826,10 +1826,22 @@ example(zstyle ':vcs_info:bzr:*' use-simple true) If you do use tt(use-simple), please report if it does `the-right-thing[tm]'. Display the revision number in yellow for tt(bzr) and tt(svn): +example(zstyle ':vcs_info:(svn|bzr):*' \ + branchformat '%b%%F{yellow}:%r') + +The doubled percent sign is explained in +ifzman(the bf(Oddities) section)ifnzman(noderef(vcs_info Oddities)). + +Alternatively, one can use the raw colour codes directly: + example(zstyle ':vcs_info:(svn|bzr):*' \ branchformat '%b%{'${fg[yellow]}'%}:%r') -If you want colors, make sure you enclose the color codes in tt(%{)var(...)tt(%}) +Normally when a variable is interpolated into a format string, the variable +needs to be tt(%)-escaped. In this example we skipped that because we assume +the value of tt(${fg[yellow]}) doesn't contain any tt(%) signs. + +Make sure you enclose the color codes in tt(%{)var(...)tt(%}) if you want to use the string provided by tt(vcs_info) in prompts. Here is how to print the VCS information as a command (not in a prompt):