0

My terminal has a white background. When commands print yellow text to the terminal, I can't see the text clearly (due to low contrast). I thought: wouldn't it be great if all the yellow text that will ever be printed were transformed to brown text? That way, I can enjoy colored output without struggling to see the printed text.

Suppose a command wants to print yellow text. Is there a way to 'hijack' the escape sequence so that brown text is printed instead? Or is there another way to achieve color transformations?

Note: I'm using gnome-terminal on Ubuntu 18.04.

3
  • Add information about which terminal do you use. For most terminals it's possible to change it's color scheme.
    – Alexander
    Commented Oct 18, 2018 at 14:20
  • I'm using GNOME terminal on Ubuntu 18.04.
    – Flux
    Commented Oct 18, 2018 at 14:43
  • Go to Edit -> Preferences -> the profile -> Colors, pick a color scheme or individual colors according to your preference. Also try to disable "Show bold text in bright colors", this way bold text remains at the darker (more readable on white background) variant.
    – egmont
    Commented Oct 18, 2018 at 21:19

1 Answer 1

1

Many of nowadays terminals (including gnome-terminal) use two or even three color palettes: 8-colors, 256-colors, and 24-bits (roughly 16x10^6 colors). However, very often the first two sets can be chosen arbitrarily from the last one and again this is the case of gnome-terminal (and for example its cousin terminator).

Now, to change particular color palette choosing from 24-bit rgb palette we need \e]4 escape code followed by changed color code number and rgb color. In your case

printf '\e[33mTEST\e[m\n'           # first print "TEST" to see yellow text
printf '\e]4;3;rgb:b0/4a/00\e\\'    # now we change yellow to brown
printf '\e[33mTEST\e[m\n'           # test again

The yellow nickname is 3 and for brown I've arbitrary chosen b04a00. After this modification you will notice that all yellow text has changed, even the one printed earlier.

1
  • Let's mention that the graphical Preferences dialog also offers a convenient way of editing the colors.
    – egmont
    Commented Oct 18, 2018 at 21:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .