All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] prompt: fix tracked files for zsh
@ 2013-04-21  8:11 Felipe Contreras
  2013-04-21  8:21 ` Andreas Schwab
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Felipe Contreras @ 2013-04-21  8:11 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Felipe Contreras

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.

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
-- 
1.8.2.1.790.g4588561

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] prompt: fix tracked files for zsh
  2013-04-21  8:11 [PATCH] prompt: fix tracked files for zsh Felipe Contreras
@ 2013-04-21  8:21 ` Andreas Schwab
  2013-04-21  8:48   ` Junio C Hamano
  2013-04-21  8:43 ` Junio C Hamano
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Andreas Schwab @ 2013-04-21  8:21 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: git, Junio C Hamano

Felipe Contreras <felipe.contreras@gmail.com> writes:

> +				if [ -n "${ZSH_VERSION-}" ]; then
> +					u="%%"
> +				else
> +					u="%"
> +				fi

aka u="%${ZSH_VERSION:+%}"

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] prompt: fix tracked files for zsh
  2013-04-21  8:11 [PATCH] prompt: fix tracked files for zsh Felipe Contreras
  2013-04-21  8:21 ` Andreas Schwab
@ 2013-04-21  8:43 ` Junio C Hamano
  2013-04-21  8:43 ` Eric Sunshine
  2013-04-21  8:43 ` Junio C Hamano
  3 siblings, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2013-04-21  8:43 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: git

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?

> 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] prompt: fix tracked files for zsh
  2013-04-21  8:11 [PATCH] prompt: fix tracked files for zsh Felipe Contreras
  2013-04-21  8:21 ` Andreas Schwab
  2013-04-21  8:43 ` Junio C Hamano
@ 2013-04-21  8:43 ` Eric Sunshine
  2013-04-21  8:43 ` Junio C Hamano
  3 siblings, 0 replies; 10+ messages in thread
From: Eric Sunshine @ 2013-04-21  8:43 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: Git List, Junio C Hamano

On Sun, Apr 21, 2013 at 4:11 AM, Felipe Contreras
<felipe.contreras@gmail.com> wrote:
> 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

s/bas/bash/

> we need to escape the % character.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] prompt: fix tracked files for zsh
  2013-04-21  8:11 [PATCH] prompt: fix tracked files for zsh Felipe Contreras
                   ` (2 preceding siblings ...)
  2013-04-21  8:43 ` Eric Sunshine
@ 2013-04-21  8:43 ` Junio C Hamano
  3 siblings, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2013-04-21  8:43 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: git

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, does 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?

> 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] prompt: fix tracked files for zsh
  2013-04-21  8:21 ` Andreas Schwab
@ 2013-04-21  8:48   ` Junio C Hamano
  2013-04-21 19:02     ` Andreas Schwab
  0 siblings, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2013-04-21  8:48 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Felipe Contreras, git

Andreas Schwab <schwab@linux-m68k.org> writes:

> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> +				if [ -n "${ZSH_VERSION-}" ]; then
>> +					u="%%"
>> +				else
>> +					u="%"
>> +				fi
>
> aka u="%${ZSH_VERSION:+%}"

Do you need/want a colon there?  Even if it is empty, as long as it
is defined we would want this, no?

>
> Andreas.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] prompt: fix tracked files for zsh
  2013-04-21  8:48   ` Junio C Hamano
@ 2013-04-21 19:02     ` Andreas Schwab
  2013-04-21 21:00       ` Felipe Contreras
  0 siblings, 1 reply; 10+ messages in thread
From: Andreas Schwab @ 2013-04-21 19:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Felipe Contreras, git

Junio C Hamano <gitster@pobox.com> writes:

> Andreas Schwab <schwab@linux-m68k.org> writes:
>
>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>
>>> +				if [ -n "${ZSH_VERSION-}" ]; then
>>> +					u="%%"
>>> +				else
>>> +					u="%"
>>> +				fi
>>
>> aka u="%${ZSH_VERSION:+%}"
>
> Do you need/want a colon there?  Even if it is empty, as long as it
> is defined we would want this, no?

The original wouldn't.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] prompt: fix tracked files for zsh
  2013-04-21 19:02     ` Andreas Schwab
@ 2013-04-21 21:00       ` Felipe Contreras
  2013-04-21 22:00         ` Junio C Hamano
  0 siblings, 1 reply; 10+ messages in thread
From: Felipe Contreras @ 2013-04-21 21:00 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Junio C Hamano, git

On Sun, Apr 21, 2013 at 2:02 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Andreas Schwab <schwab@linux-m68k.org> writes:
>>
>>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>>
>>>> +                           if [ -n "${ZSH_VERSION-}" ]; then
>>>> +                                   u="%%"
>>>> +                           else
>>>> +                                   u="%"
>>>> +                           fi
>>>
>>> aka u="%${ZSH_VERSION:+%}"
>>
>> Do you need/want a colon there?  Even if it is empty, as long as it
>> is defined we would want this, no?
>
> The original wouldn't.

I thought you were trying to improve the original ;)

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] prompt: fix tracked files for zsh
  2013-04-21 21:00       ` Felipe Contreras
@ 2013-04-21 22:00         ` Junio C Hamano
  2013-04-21 22:32           ` Felipe Contreras
  0 siblings, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2013-04-21 22:00 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: Andreas Schwab, git

Felipe Contreras <felipe.contreras@gmail.com> writes:

> On Sun, Apr 21, 2013 at 2:02 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
>> Junio C Hamano <gitster@pobox.com> writes:
>>
>>> Andreas Schwab <schwab@linux-m68k.org> writes:
>>>
>>>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>>>
>>>>> +                           if [ -n "${ZSH_VERSION-}" ]; then
>>>>> +                                   u="%%"
>>>>> +                           else
>>>>> +                                   u="%"
>>>>> +                           fi
>>>>
>>>> aka u="%${ZSH_VERSION:+%}"
>>>
>>> Do you need/want a colon there?  Even if it is empty, as long as it
>>> is defined we would want this, no?
>>
>> The original wouldn't.
>
> I thought you were trying to improve the original ;)

OK, so I _think_ everybody is in agreement that the patch should
look like this.  OK?

-- >8 --
From: Felipe Contreras <felipe.contreras@gmail.com>
Subject: [PATCH] prompt: fix untracked files for zsh

With "bash.showUntrackedFiles" option, presense of untracked files
is signalled by adding a per-cent sign '%' to the prompt.  But
because '%' is used as an escape character to introduce prompt
customization in zsh (just like bash prompt uses '\' to escape \u,
\h, etc.), we need to say '%%' to get a literal per-cent.

Helped-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-prompt.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 756a951..054c52e 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -340,7 +340,7 @@ __git_ps1 ()
 			   [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
 			   [ -n "$(git ls-files --others --exclude-standard)" ]
 			then
-				u="%"
+				u="%${ZSH_VERSION+%}"
 			fi
 
 			if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] prompt: fix tracked files for zsh
  2013-04-21 22:00         ` Junio C Hamano
@ 2013-04-21 22:32           ` Felipe Contreras
  0 siblings, 0 replies; 10+ messages in thread
From: Felipe Contreras @ 2013-04-21 22:32 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Andreas Schwab, git

On Sun, Apr 21, 2013 at 5:00 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> On Sun, Apr 21, 2013 at 2:02 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
>>> Junio C Hamano <gitster@pobox.com> writes:
>>>
>>>> Andreas Schwab <schwab@linux-m68k.org> writes:
>>>>
>>>>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>>>>
>>>>>> +                           if [ -n "${ZSH_VERSION-}" ]; then
>>>>>> +                                   u="%%"
>>>>>> +                           else
>>>>>> +                                   u="%"
>>>>>> +                           fi
>>>>>
>>>>> aka u="%${ZSH_VERSION:+%}"
>>>>
>>>> Do you need/want a colon there?  Even if it is empty, as long as it
>>>> is defined we would want this, no?
>>>
>>> The original wouldn't.
>>
>> I thought you were trying to improve the original ;)
>
> OK, so I _think_ everybody is in agreement that the patch should
> look like this.  OK?
>
> -- >8 --
> From: Felipe Contreras <felipe.contreras@gmail.com>
> Subject: [PATCH] prompt: fix untracked files for zsh
>
> With "bash.showUntrackedFiles" option,

Not exactly correct, it can also be GIT_PS1_SHOWUNTRACKEDFILES.

> presense of untracked files
> is signalled by adding a per-cent sign '%' to the prompt.  But
> because '%' is used as an escape character to introduce prompt
> customization in zsh (just like bash prompt uses '\' to escape \u,
> \h, etc.), we need to say '%%' to get a literal per-cent.

Otherwise it's fine.

Cheers.

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-04-21 22:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-21  8:11 [PATCH] prompt: fix tracked files for zsh Felipe Contreras
2013-04-21  8:21 ` Andreas Schwab
2013-04-21  8:48   ` Junio C Hamano
2013-04-21 19:02     ` Andreas Schwab
2013-04-21 21:00       ` Felipe Contreras
2013-04-21 22:00         ` Junio C Hamano
2013-04-21 22:32           ` Felipe Contreras
2013-04-21  8:43 ` Junio C Hamano
2013-04-21  8:43 ` Eric Sunshine
2013-04-21  8:43 ` Junio C Hamano

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.