From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14554 invoked by alias); 22 Feb 2015 20:07:42 -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: 19887 Received: (qmail 18141 invoked from network); 22 Feb 2015 20:07:40 -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=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=w4vrOVKFg6m3jBRgQ1CgNsliGH/XYZTG+c3zrT6cEC0=; b=drAmaJi0K/zm8MzAvqa0KQoB2EpA46p8Tc1pRqtojkKTARNazSPyixsiBLbWItCyM7 P2Djwwqf71HWJXGEHH08INLVPGKqKNwdhUI6Ama7ArsUVlxPmQh8wcVuPXlQogD9vgVp 6ktAFgWUmSJfpY/3Z4TGjSpHR5Y27JAjx2i2IQ6IA7jTcizLiBXa/CPcWTkNUvI1mj4R GByhTGZj2txktUTIVfMWQMjWY8QDWcKQOOfIj02QQdNtgPjJYyUw2zz2F/xAIwzXoSJP xw7JQoB/OjBNaKRnw8XX/3orINyY0KPBNrekgwjUKaG4Qv3l4hJsL2hsGFzWC6Ovf4CL rhMQ== X-Received: by 10.42.195.205 with SMTP id ed13mr8196806icb.58.1424635657284; Sun, 22 Feb 2015 12:07:37 -0800 (PST) Date: Sun, 22 Feb 2015 15:07:35 -0500 From: junkcommander0@gmail.com To: zsh-users@zsh.org Subject: Re: ANSI bg colour outside of prompt area Message-ID: <20150222200735.GA14096@wintermute> References: <20150222132310.GA18377@wintermute> <150222111007.ZM18687@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <150222111007.ZM18687@torch.brasslantern.com> User-Agent: Mutt/1.5.23 (2014-03-12) 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.