git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] prompt: fix tracked files for zsh

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 21, 2013, 08:43 UTC
Message-ID
<7vr4i4uvdy.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1366531890-19899-1-git-send-email-felipe.contreras@gmail.com>
Felipe Contreras <felipe.contreras@gmail.com> writes:
> When this option is enabled, the prompt gets totally screwed in zsh
> because all the codes start with % in zsh (like they are \ in bas). So
> we need to escape the % character.

It is not that I do not believe that $u needs to duplicate %% in ZSH, but I hate it when I do not understand the explanation. Could you help me clarify what you meant by "codes" and "like they are \ in bas"?

Are you referring to things like \u (user) \h (host) as "code" and "bas" was a simple typo of "bash"? In other words, is my reading below:

	... because '%' is used as an introducer of prompt
	customization in zsh (just like bash prompt uses '\' to
	introduce \u, \h, etc.), we need to give '%%' to get a
	literal per-cent character.
match what you meant to say?
Show 22 quoted lines
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  contrib/completion/git-prompt.sh | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
> index 756a951..4bedbcc 100644
> --- a/contrib/completion/git-prompt.sh
> +++ b/contrib/completion/git-prompt.sh
> @@ -340,7 +340,11 @@ __git_ps1 ()
>  			   [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
>  			   [ -n "$(git ls-files --others --exclude-standard)" ]
>  			then
> -				u="%"
> +				if [ -n "${ZSH_VERSION-}" ]; then
> +					u="%%"
> +				else
> +					u="%"
> +				fi
>  			fi
>  
>  			if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
Previous: Felipe ContrerasNext: Eric Sunshine
Message 8 of 10 in “prompt: fix tracked files for zsh”
  1. prompt: fix tracked files for zshFelipe Contreras, Apr 21, 2013
  2. Andreas SchwabApr 21, 2013
  3. Junio C HamanoApr 21, 2013
  4. Andreas SchwabApr 21, 2013
  5. Felipe ContrerasApr 21, 2013
  6. Junio C HamanoApr 21, 2013
  7. Felipe ContrerasApr 21, 2013
  8. Junio C HamanoApr 21, 2013
  9. Eric SunshineApr 21, 2013
  10. Junio C HamanoApr 21, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.