All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"SZEDER Gábor" <szeder.dev@gmail.com>,
	"Felipe Contreras" <felipe.contreras@gmail.com>
Subject: [PATCH v3 07/29] completion: prompt: fix color for Zsh
Date: Tue, 27 Oct 2020 20:06:50 -0600	[thread overview]
Message-ID: <20201028020712.442623-8-felipe.contreras@gmail.com> (raw)
In-Reply-To: <20201028020712.442623-1-felipe.contreras@gmail.com>

We don't need PROMPT_COMMAND in Zsh; we are already using %F{color} %f,
which in turn use %{ and %}, which are the equivalent of Bash's
\[ and \].

We can use as many colors as we want and output directly into PS1
(or RPS1) without the risk of buffer wrapping issues.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-prompt.sh | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 16260bab73..54e123d632 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -97,7 +97,8 @@
 # If you would like a colored hint about the current dirty state, set
 # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
 # the colored output of "git status -sb" and are available only when
-# using __git_ps1 for PROMPT_COMMAND or precmd.
+# using __git_ps1 for PROMPT_COMMAND or precmd in Bash,
+# but always available in Zsh.
 #
 # If you would like __git_ps1 to do nothing in the case when the current
 # directory is set up to be ignored by git, then set
@@ -553,9 +554,11 @@ __git_ps1 ()
 
 	local z="${GIT_PS1_STATESEPARATOR-" "}"
 
-	# NO color option unless in PROMPT_COMMAND mode
-	if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
-		__git_ps1_colorize_gitstring
+	# NO color option unless in PROMPT_COMMAND mode or it's Zsh
+	if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
+		if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then
+			__git_ps1_colorize_gitstring
+		fi
 	fi
 
 	b=${b##refs/heads/}
-- 
2.29.1


  parent reply	other threads:[~2020-10-28 23:43 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-28  2:06 [PATCH v3 00/29] completion: zsh: latest patches Felipe Contreras
2020-10-28  2:06 ` [PATCH v3 01/29] completion: zsh: fix __gitcomp_direct() Felipe Contreras
2020-10-28  2:06 ` [PATCH v3 02/29] completion: zsh: fix name due to broken autoloading Felipe Contreras
2020-10-28  2:06 ` [PATCH v3 03/29] completion: zsh: fix bash script extension Felipe Contreras
2020-10-28  2:06 ` [PATCH v3 04/29] completion: zsh: reorganize install instructions Felipe Contreras
2020-10-28  2:06 ` [PATCH v3 05/29] completion: zsh: fix for directories with spaces Felipe Contreras
2020-10-28  2:06 ` [PATCH v3 06/29] completion: zsh: update slave script locations Felipe Contreras
2020-10-28  2:06 ` Felipe Contreras [this message]
2020-10-28  2:06 ` [PATCH v3 08/29] completion: zsh: fix for command aliasing Felipe Contreras
2020-10-28  2:06 ` [PATCH v3 09/29] completion: bash: synchronize zsh wrapper Felipe Contreras
2020-10-28  2:06 ` [PATCH v3 10/29] completion: bash: remove " Felipe Contreras
2020-10-28  2:06 ` [PATCH v3 11/29] completion: zsh: fix completion for --no-.. options Felipe Contreras
2020-10-28  2:06 ` [PATCH v3 12/29] completion: fix conflict with bashcomp Felipe Contreras
2020-10-28  2:06 ` [PATCH v3 13/29] completion: zsh: add missing direct_append Felipe Contreras
2020-10-28  2:06 ` [PATCH v3 14/29] completion: zsh: fix splitting of words Felipe Contreras
2020-10-28  2:06 ` [PATCH v3 15/29] completion: zsh: simplify compadd functions Felipe Contreras
2020-10-28  2:06 ` [PATCH v3 16/29] completion: zsh: simplify direct compadd Felipe Contreras
2020-10-28  2:07 ` [PATCH v3 17/29] completion: zsh: trivial cleanup Felipe Contreras
2020-10-28  2:07 ` [PATCH v3 18/29] completion: zsh: simplify nl_append Felipe Contreras
2020-10-28  2:07 ` [PATCH v3 19/29] completion: zsh: simplify file_direct Felipe Contreras
2020-10-28  2:07 ` [PATCH v3 20/29] completion: zsh: shuffle functions around Felipe Contreras
2020-10-28  2:07 ` [PATCH v3 21/29] completion: zsh: refactor command completion Felipe Contreras
2020-10-28  2:07 ` [PATCH v3 22/29] completion: zsh: improve command tags Felipe Contreras
2020-10-28  2:07 ` [PATCH v3 23/29] completion: zsh: add alias descriptions Felipe Contreras
2020-10-28  2:07 ` [PATCH v3 24/29] completion: zsh: trivial simplification Felipe Contreras
2020-10-28  2:07 ` [PATCH v3 25/29] completion: zsh: add simple version check Felipe Contreras
2020-10-28  2:07 ` [PATCH v3 26/29] completion: bash: trivial cleanup Felipe Contreras
2020-10-28  2:07 ` [PATCH v3 27/29] completion: bash: cleanup cygwin check Felipe Contreras
2020-10-28  2:07 ` [PATCH v3 28/29] completion: bash: remove old compat wrappers Felipe Contreras
2020-10-28  2:07 ` [PATCH v3 29/29] Update copyright notices Felipe Contreras
2020-10-29 17:43 ` [PATCH v3 00/29] completion: zsh: latest patches Junio C Hamano

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=20201028020712.442623-8-felipe.contreras@gmail.com \
    --to=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=szeder.dev@gmail.com \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.