Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Prompt width miscomputed with conditional substring
- X-seq: zsh-workers 34855
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: ZyX <kp-pav@xxxxxxxxx>
- Subject: Re: Prompt width miscomputed with conditional substring
- Date: Mon, 6 Apr 2015 23:57:18 +0200
- Cc: Bernie Innocenti <bernie@xxxxxxxxxxx>, "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=/d8RRirXzDl6cvPY6WaDSznTHTfudrX7rAjg+pUUvFM=; b=zcH4+tbbVN4MHfFiwK+YI0fGGfY7sFH1QKLDGDCsCIeUcvsdZhaLRHS69OjHJKPisy VhZIxCXoESiHrunJQmwTK6XlDhkGrJQ/xWkD/iSFIWovC8go4hO3P5ewUs0zps/PGbVx WTghofzTLhHhrlhJw3t83Aj3ivw+Ospkzd6BNMgVEI6fN6o9jion65N3l3Fvqj4cuF70 GMcFxAGpTiqoVdywePI4fK1nAKeSB2TWKYwGnk3VBviVP+R7Z0FhcNVJL9WhQ4ut4w1g V3zpk28z5oSgBKFluNskiAWOTPrOtu2JfKcPRwBvE7VoCYynW0GNIcEmp4X2DMa9vUmI qx4A==
- In-reply-to: <1717811428355777@web11o.yandex.ru>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <5522F467.8060808@codewiz.org> <1717811428355777@web11o.yandex.ru>
On Mon, Apr 6, 2015 at 11:29 PM, ZyX <kp-pav@xxxxxxxxx> wrote:
> 07.04.2015, 00:09, "Bernie Innocenti" <bernie@xxxxxxxxxxx>:
>> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author