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.

  • Add information about which terminal do you use. For most terminals it's possible to change it's color scheme. – Alexander Oct 18 '18 at 14:20
  • I'm using GNOME terminal on Ubuntu 18.04. – Flux Oct 18 '18 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 Oct 18 '18 at 21:19
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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.