Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: End boldface also ends background color

On Tue, Mar 22, 2016 at 8:44 PM, Dominik Ritter
<dritter03@xxxxxxxxxxxxxx> wrote:
> Hi List!
> I have a Problem regarding boldface mode. If I change the background
> color of a string, and want to set a part of that string in boldface,
> the background color gets ended as well.
> Example:
> print -P '%K{black} %F{white}%Bhello%b world'
> The boldface ending sequence, also ends the background color. So only
> "hello" gets printed white on black, "world" gets printed in white
> (without background).
> This seems like a bug to me.. Anyone else can confirm that?
> Btw. I am on ZSH 5.2 (latest homebrew).
> Of course, there are some workarounds:
> - Start the background color again, after ending boldface.
> Well. Possible, but quite verbose.
> - Use $fg_bold[white] and $fg_no_bold[white] instead of %B and %b.
> Also quite verbose..

The code for ending bold sequences is usually ^[[22m but %b sends
^[[0m which resets most things. As far as I know, termcap
unfortunately doesn't include the code that only ends bold, so there's
no way for zsh to know what it is. Zsh doesn't hardcode any of these
sequences because they can vary across terminals.

Mikael Magnusson

Messages sorted by: Reverse Date, Date, Thread, Author