I would like to colorize output of one long complex interactive BASH script to make it easier for the user to work with it. I have learned how to use tput, but my question is more matter of design:

Terminal style is usually whitish background and black text, or black background and white/yellow/light green text. If I need then, lets say, three colors for my script, how to choose them to look good on any terminal?

I have seen once even terminal with pink background with white snowflakes and black text... Well, I could explicitly set black background and colorize output as I wish, but I don't wish to overwrite user's settings.

Is there any general advice how to deal with that?

closed as primarily opinion-based by Thomas Dickey, Jeff Schaller, Stephen Harris, G-Man, taliezin Jul 14 '16 at 8:20

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Maybe first pick bad colors - like light yellow and dark brown - and print two messages to the screen at the start of the script. Print one message in yellow and the other in brown. Make one say "Press SPACEBAR to continue" and the other should ask for the ENTER key. Whichever key is pressed is almost definitely the one which the user was more easily able to read. – mikeserv Oct 8 '15 at 16:19

I believe that best practice is not to try and find colors that work with all backgrounds, but to adapt to the current background. This is e.g. the default for vim highlighting schemes, which have "light" and "dark" variants. You can read the background color from the environment and choose your colors accordingly: Use light colors if the background is dark, and dark if the background is light.

  • The referenced page reports some issues, so that I wonder how reliable the detection of background is... Otherwise it is interesting idea. – Tilia Oct 9 '15 at 15:25
  • If you are using xterm, the control sequence is reliable. If you are not, there is the less-reliable convention of environment variable. Environment variables can be inherited... – Thomas Dickey Oct 29 '15 at 22:41

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