From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23422 invoked by alias); 22 Feb 2015 19:10:14 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19886 Received: (qmail 22260 invoked from network); 22 Feb 2015 19:10:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=Pd9IXZlY c=1 sm=1 tr=0 a=FT8er97JFeGWzr5TCOCO5w==:117 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=0HtSIViG9nkA:10 a=pGLkceISAAAA:8 a=OJuTVG_2ulHBk0rtaJ0A:9 a=CjuIK1q_8ugA:10 From: Bart Schaefer Message-id: <150222111007.ZM18687@torch.brasslantern.com> Date: Sun, 22 Feb 2015 11:10:07 -0800 In-reply-to: <20150222132310.GA18377@wintermute> Comments: In reply to junkcommander0@gmail.com "ANSI bg colour outside of prompt area" (Feb 22, 8:23am) References: <20150222132310.GA18377@wintermute> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: ANSI bg colour outside of prompt area Cc: junkcommander0@gmail.com MIME-version: 1.0 Content-type: text/plain; charset=us-ascii 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.