* Prompt width miscomputed with conditional substring
@ 2015-04-06 21:02 Bernie Innocenti
2015-04-06 21:29 ` ZyX
0 siblings, 1 reply; 3+ messages in thread
From: Bernie Innocenti @ 2015-04-06 21:02 UTC (permalink / raw)
To: zsh-workers
My zsh prompt is:
local ret_status="%(?:%{$fg_bold[green]%}%%:%{$fg_bold[red]%}%%%s)"
PROMPT="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m:%{$fg[yellow]%}%~
%(1j,$fg[cyan][%j],)${ret_status}%{$reset_color%} "
When I have background jobs, the prompt becomes 3 characters longer and
command-line editing seems to wrap at the wrong column.
This is also reproducible with zsh built from git (zsh-5.0.7-374-gd4f50f2).
--
_ // Bernie Innocenti
\X/ http://codewiz.org
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Prompt width miscomputed with conditional substring
2015-04-06 21:02 Prompt width miscomputed with conditional substring Bernie Innocenti
@ 2015-04-06 21:29 ` ZyX
2015-04-06 21:57 ` Mikael Magnusson
0 siblings, 1 reply; 3+ messages in thread
From: ZyX @ 2015-04-06 21:29 UTC (permalink / raw)
To: Bernie Innocenti, zsh-workers
07.04.2015, 00:09, "Bernie Innocenti" <bernie@codewiz.org>:
> My zsh prompt is:
>
> local ret_status="%(?:%{$fg_bold[green]%}%%:%{$fg_bold[red]%}%%%s)"
> PROMPT="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m:%{$fg[yellow]%}%~
> %(1j,$fg[cyan][%j],)${ret_status}%{$reset_color%} "
>
> When I have background jobs, the prompt becomes 3 characters longer and
> command-line editing seems to wrap at the wrong column.
>
> This is also reproducible with zsh built from git (zsh-5.0.7-374-gd4f50f2).
>
> --
> _ // Bernie Innocenti
> \X/ http://codewiz.org
This is expected because you have not wrapped `$fg[cyan]` properly after %(1j. This is not a bug.
I would highly suggest to drop and forget colors function. If you need colors just use %F{green}…%f to highlight with green. Specifically read man zshmisc, section “SIMPLE PROMPT ESCAPES”, subsection “Visual effects”.
If you think that $fg[cyan] is useful outside of prompt note that you may use ${(%):-%F{green}} (though `$fg[cyan]` is better when you don’t have to write it as `%{$fg[cyan]%}` and can’t just write `%F{green}` because you are not in prompt).
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Prompt width miscomputed with conditional substring
2015-04-06 21:29 ` ZyX
@ 2015-04-06 21:57 ` Mikael Magnusson
0 siblings, 0 replies; 3+ messages in thread
From: Mikael Magnusson @ 2015-04-06 21:57 UTC (permalink / raw)
To: ZyX; +Cc: Bernie Innocenti, zsh-workers
On Mon, Apr 6, 2015 at 11:29 PM, ZyX <kp-pav@yandex.ru> wrote:
> 07.04.2015, 00:09, "Bernie Innocenti" <bernie@codewiz.org>:
>> My zsh prompt is:
>>
>> local ret_status="%(?:%{$fg_bold[green]%}%%:%{$fg_bold[red]%}%%%s)"
>> PROMPT="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m:%{$fg[yellow]%}%~
>> %(1j,$fg[cyan][%j],)${ret_status}%{$reset_color%} "
>>
>> When I have background jobs, the prompt becomes 3 characters longer and
>> command-line editing seems to wrap at the wrong column.
>>
>> This is also reproducible with zsh built from git (zsh-5.0.7-374-gd4f50f2).
>
> This is expected because you have not wrapped `$fg[cyan]` properly after %(1j. This is not a bug.
>
> I would highly suggest to drop and forget colors function. If you need colors just use %F{green}…%f to highlight with green. Specifically read man zshmisc, section “SIMPLE PROMPT ESCAPES”, subsection “Visual effects”.
>
> If you think that $fg[cyan] is useful outside of prompt note that you may use ${(%):-%F{green}} (though `$fg[cyan]` is better when you don’t have to write it as `%{$fg[cyan]%}` and can’t just write `%F{green}` because you are not in prompt).
It's probably worth noting that inside double quotes, you need to
quote the closing brace of %F with \} or it will end the ${ brace as
well.
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-04-06 21:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-06 21:02 Prompt width miscomputed with conditional substring Bernie Innocenti
2015-04-06 21:29 ` ZyX
2015-04-06 21:57 ` Mikael Magnusson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).