Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Prompt width miscomputed with conditional substring
- X-seq: zsh-workers 34854
- From: ZyX <kp-pav@xxxxxxxxx>
- To: Bernie Innocenti <bernie@xxxxxxxxxxx>, "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Re: Prompt width miscomputed with conditional substring
- Date: Tue, 07 Apr 2015 00:29:37 +0300
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1428355778; bh=XD/lKEY7Xr5PeXw5+O1E1iGioIxtNe4ZemB76b8ERSQ=; h=From:To:In-Reply-To:References:Subject:Date; b=iE3XAfl/U+wF3pWCNDDJHluqA/tQFUMII6AlbB7601nuoPkZhOoycl8Mr7xw4NjLj z8BGzsUYlH1SBVIkrmLF7pYVzJzpRU11cwZUgNnsW3w9I8UIozB7hE5ldZpAIEFLQX 0wkBTx3ONG3BK0l16vmSSa9Ptq22p/Tb/kguT66o=
- In-reply-to: <5522F467.8060808@codewiz.org>
- 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>
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).
>
> --
> _ // 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).
Messages sorted by:
Reverse Date,
Date,
Thread,
Author