zsh-users
 help / color / mirror / code / Atom feed
From: junkcommander0@gmail.com
To: zsh-users@zsh.org
Subject: Re: ANSI bg colour outside of prompt area
Date: Sun, 22 Feb 2015 15:07:35 -0500	[thread overview]
Message-ID: <20150222200735.GA14096@wintermute> (raw)
In-Reply-To: <150222111007.ZM18687@torch.brasslantern.com>

Thanks so much Guys!

I completely understand, changing the terminal background doesn't look 
like it's something that is supposed to be able to be done. 

} PROMPT=$'%K{yellow}%{\e[J%}'"$PROMPT"
Thank you very much, This works!! 

Unfortunately, within tmux it only colours the prompt. Outside of it 
though it works beautifully. I have a feeling you're right though, if 
I'm going to get this to work reliably I'll have to see if I can 
sandwich a little function into st's source for changing the value of 
the background colour.

It's a little out of my league for now, but it's something to look 
forward to as I learn a little more :).


Just in case you're curious, I do have custom colours set up in my 
terminal, but I used to use this to quickly switch the terminal 
background colour to white if I was in a dark room and someone flicked a 
light on. It's kind of petty, but it was a nifty little trick that made 
it easier to see the screen when there was a glare on it.

As a workaround for now I have a little alias that switches the value of 
the background colour in st's config.h, and recompiles it. It's not 
quite the same as toggling it in the terminal I'm working in, but it's 
not terribly difficult to open a new terminal with a different 
background colour.


A great week/weekend to all of you,

Will

On Sun, Feb 22, 2015 at 11:10:07AM -0800, Bart Schaefer wrote:
>On Feb 22,  8:23am, junkcommander0@gmail.com wrote:
>}
>} I was wondering if anyone has had any success setting BG colours in
>} their terminal with ANSI escape sequences or with some other method.
>
>If you're using a graphical desktop with terminal emulators for shell
>windows, you'd typically want to do this via the emulator configuration
>instead of by sending ANSI sequences.  E.g.
>
>    xterm -fg yellow -bg black
>
>This gives you a lot more variety of possible colors to chose from; you
>can use the entire graphical color palette rather than being limited to
>what the emulator defines as e.g. "bold + yellow" for ANSI.
>
>However ...
>
>} I had some aliases with escape sequences that I used for bash and shell
>} that would change the background colour. The colour was never reset, and
>} clearing the screen would change the entire terminal's background
>} colour.
>[...]
>} 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.
>
>Also ZLE emits a "clear to end of screen" before printing the prompt to
>remove anything that another program might have left behind.  This is
>to keep your prompt from getting obscured by overstriking something.
>However, combined with the color reset, that has the effect of restoring
>the default background color for everything below the prompt position.
>
>So the trick is to emit the clear-screen again after changing the color
>in the prompt.
>
>    PROMPT=$'%K{yellow}%{\e[J%}'"$PROMPT"
>
>However if you run something like "man" that applies it own boldface or
>underlining to the text, you'll see the default colors get restored in
>the middle of the output.  This happens in bash too.  You will be much
>better off changing the terminal's idea of the defaults.


  reply	other threads:[~2015-02-22 20:07 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-22 13:23 junkcommander0
2015-02-22 16:52 ` Ray Andrews
2015-02-22 19:10 ` Bart Schaefer
2015-02-22 20:07   ` junkcommander0 [this message]
2015-02-22 21:55   ` ZyX
2015-02-23  1:22     ` Bart Schaefer
2015-02-23  1:55       ` Vincent Lefevre
2015-02-23 12:34       ` ZyX
2015-02-22 23:10   ` Ray Andrews
2015-02-23  0:10     ` ZyX
2015-02-23  0:28       ` Kurtis Rader
2015-02-23  1:14         ` Bart Schaefer
2015-02-23  1:44           ` Kurtis Rader
2015-02-23  2:04             ` Vincent Lefevre
2015-02-23  2:18               ` Kurtis Rader
2015-02-23  3:41             ` Ray Andrews
2015-02-23  4:03               ` Kurtis Rader
2015-02-23  5:34                 ` Ray Andrews
2015-02-23  4:14               ` Kurtis Rader
2015-02-23  5:49                 ` Bart Schaefer
2015-02-23  9:46               ` Vincent Lefevre
2015-02-23 16:36                 ` Bart Schaefer
2015-02-23 16:51                   ` Ray Andrews
2015-02-24  2:53                     ` Bart Schaefer
2015-02-24  3:49                       ` junkcommander0
2015-02-24  4:33                         ` Ray Andrews
2015-02-24  4:25                       ` Ray Andrews
2015-02-24  8:36                   ` Vincent Lefevre
2015-02-23  5:27             ` Bart Schaefer
2015-02-23  1:51           ` Vincent Lefevre
2015-02-23  0:55       ` Ray Andrews
2015-02-23  1:36       ` Vincent Lefevre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150222200735.GA14096@wintermute \
    --to=junkcommander0@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).