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

Re: ANSI bg colour outside of prompt area



23.02.2015, 02:43, "Ray Andrews" <rayandrews@xxxxxxxxxxx>:
> On 02/22/2015 11:10 AM, Bart Schaefer wrote:
>>  } In zsh, the background color gets reset once the characters have been
>>  } printed.
>>
>>  That's intentional so that a misbehaving program can't e.g. cause your
>>  prompt to become invisible by changing the background to the same color
>>  as your prompt foreground.
>
> That makes sense, and I suppose, as you say, the more direct thing is to
> manipulate the terminal, tho that means a restart anytime you wanted one
> of those color changes, and my xfce4-terminal doesn't seem to permit
> command line color changes anyway.  But to the extent that zsh supports
> color, shouldn't the colors stay set until they are explicitly changed?
> I see in bash:
>
> echo -e "\e[41m"
> red
> red
> red
> echo -e "\e[0m"
> normal
> normal
> normal
>
> I get exactly what I ask for--when I want to return to defaults, I say so.
>
> So, would it be possible to have, say, an option to stop ZLE from
> clearing the screen as it does?  I can see that the zsh way is safer,
> but being able to turn it off sounds like a cool option as well, and
> friendly to our bash converts besides.

It is the first time I saw any “bash convert” needing this feature. I think 
that if you create a poll you will see that almost everybody will vote for 
either “WTF are you talking about?”, “Who may need this behaviour?” or “Sure, 
this option is cool. Doesn’t mean I am going to ever use it though.”

I have tested `echo $'\e[41m' ; {command}` with the following colored commands 
and here is what I have:

eix       | First line has red background after the text, to the very end.
hg diff   | Same.
git diff  | First line has text with red background, red ends as text ends.
grep      | First file name has red background (multifile search) and nothing 
          | after it. Single file match has highlight up until the first match 
          | ends (match is highlighted).
ag        | Again red background ends when the first highlighted string ends.
powerline | Red background appears on the first line and disappears completely 
          | when powerline outputs something.


No color program I know bothers to stop its highlighting any way other then 
catch-all `\e[0m` or similar `\e[m`, so to use this feature you should disable 
colors. Many terminals support changing background color via escape sequences 
like the one from my first message (st appears not to support this, but it even 
has no scrollback buffer, so it is not surprising). This leaves very little 
space in which feature may be considered useful and cannot be implemented the 
other way.

Thus I would say that implementing such option is a pure waste of time.



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