[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Colouring commands on terminal to be green
From: |
lisa-asket |
Subject: |
Colouring commands on terminal to be green |
Date: |
Sun, 27 Jun 2021 19:24:47 +0200 (CEST) |
Well, if you use terminal-independent method of configuration, what do you do
for 256 colours?
From: Greg Wooledge <greg@wooledge.org>
To: help-bash@gnu.org
Subject: Re: Colouring commands on terminal to be green
Date: 27/06/2021 18:43:03 Europe/Paris
> From: Koichi Murase <myoga.murase@gmail.com>
> I'm not sure if this works in every possible case because it's merely
> a hack, but you may modify PS1 and PS0 as
>
> PS1=$PS1'\[\e[32m\]'
> PS0='\e[39m'$PS0
On Sun, Jun 27, 2021 at 05:32:13PM +0200, lisa-asket@perso.be wrote:
> What isĀ "\e[39m" exactly ?
This is one of the reasons why I don't endorse hard-coding escape
sequences in your configuration. Not only are the escape sequences
incomprehensible, but they also aren't the same for every terminal
type.
It should be reasonable to guess from context that what Koichi's PS0 is
supposed to do is reset the green color back to the original foreground
color. (Whether it actually does that will depend on your terminal.)
You've got the PS1 variable which is expanded and printed *before*
the user begins typing, and then the PS0 variable which is expanded
and printed *after* the user finishes typing, but before the command
is executed.
A more terminal-independent method of configuration would look something
like this:
green=$(tput setaf 2)
normal=$(tput sgr0)
PS1=$PS1'\[$green\]'
PS0='$normal'$PS0
- Colouring commands on terminal to be green, lisa-asket, 2021/06/27
- Re: Colouring commands on terminal to be green, Koichi Murase, 2021/06/27
- Colouring commands on terminal to be green, lisa-asket, 2021/06/27
- Re: Colouring commands on terminal to be green, Greg Wooledge, 2021/06/27
- Colouring commands on terminal to be green,
lisa-asket <=
- Re: Colouring commands on terminal to be green, Greg Wooledge, 2021/06/27
- Colouring commands on terminal to be green, lisa-asket, 2021/06/27
- Re: Colouring commands on terminal to be green, Greg Wooledge, 2021/06/27
- Colouring commands on terminal to be green, lisa-asket, 2021/06/27