From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9374 invoked by alias); 22 Feb 2015 22:01:44 -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: 19888 Received: (qmail 232 invoked from network); 22 Feb 2015 22:01:29 -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,T_FSL_HELO_BARE_IP_2 autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1424642127; bh=3qbvrJBPipqY33kQpIO+TgWXn192r7LGlzY0ymV6KcU=; h=From:To:Cc:In-Reply-To:References:Subject:Date; b=rossLsbNpm9H//nnzm6petFDOqU0OLrBEnv0ccHJaE15Nmmk2HlrI6+fzTEhMSVV/ 9BAtyCO45PM6rfX7aRkQogrZ5nlPypaMc0qHJOtRWX3GAu3MQnVbOGD7SZ0iSyJnOg 6ABB6ATmggAcf0DtsCxUZSWpZIjuonSlacm25msE= From: ZyX To: Bart Schaefer , "zsh-users@zsh.org" Cc: "junkcommander0@gmail.com" In-Reply-To: <150222111007.ZM18687@torch.brasslantern.com> References: <20150222132310.GA18377@wintermute> <150222111007.ZM18687@torch.brasslantern.com> Subject: Re: ANSI bg colour outside of prompt area MIME-Version: 1.0 Message-Id: <4497961424642126@web27g.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Mon, 23 Feb 2015 00:55:26 +0300 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=koi8-r 22.02.2015, 22:12, "Bart Schaefer" : > 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. Most of time you can use just the same 24-bit palette when setting color via command-line arguments, .Xresources and escape sequences, except that not when you use the strange method OP uses. *Currently* you can as well use 24-bit palette for highlighting *everything*: via š š \e[{fg|bg};2;{Red};{Green};{Blue}m (where fg is 38, bg is 48, Red, Green and Blue are decimal numbers 0..255). Colors set this way are treated (including clearing and replacing with another color) just like any other color from 4- or 8-bit palette. This is supported by konsole (it is the oldest terminal supporting this), st, vte, iTerm2 (Mac OS X), ConEmu (Windows). This functionality was added to terminals after some time I created patch for Vim to use 24-bit colors (not merged) and also added this to powerline (first patch was sent to mailing list brought this capability to the public attention, powerline was a follow-up and less useful due to the lack of releases on that stage and hence announcements). ConEmu was a great example of how proper internal implementation makes such changes easy: it took only 38 minutes to add support for 24-bit color from the time I pointed out where these sequences are described to the ConEmu author (2.5 hours from the time I pointed out that such a thing exists) (http://habrahabr.ru/post/164687/#comment_5671059, Russian text only). On the other side, xterm was first to add support for these escape sequences and *still* does not have support for true color (it simply takes closes (in RGB space) color from its 8-bit palette when it sees such sequences). > 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. I am wondering whether same thing may apply to \C-n (0x0E, Shift Out). It is the second annoying thing that may garble everything, much more annoying since it changes the view of most characters and I have to type either `echo $'\ec'` or `echo $'\c-o'`. I mean, whether it makes sense to output \C-o to drop SO mode by default just like it is done currently with colors. > > 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.