Zsh Mailing List Archive
Messages sorted by:
Re: ANSI bg colour outside of prompt area
- X-seq: zsh-users 19886
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: ANSI bg colour outside of prompt area
- Date: Sun, 22 Feb 2015 11:10:07 -0800
- Cc: junkcommander0@xxxxxxxxx
- In-reply-to: <20150222132310.GA18377@wintermute>
- List-help: <mailto:email@example.com>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:firstname.lastname@example.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20150222132310.GA18377@wintermute>
On Feb 22, 8:23am, junkcommander0@xxxxxxxxx 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.
} 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
} In zsh, the background color gets reset once the characters have been
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.
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.
Messages sorted by: