Shell – How to permanently change both STDOUT and STDERR color to grey

colorsosxshellterminal

This question is similar to
Can I configure my shell to print STDERR and STDOUT in different colors?

But I am looking for a solution that will allow me to change both STDOUT and STDERR to ONE color. I am not trying to set different color for STDOUT and STDERR, as this is problematic and may create problems, mentioned in the answer from the link above.

I apologize, as I don't know much about Unix and Linux. I am looking for a solution that can allow me to add couple lines to my .bashrc or .bash_profile and permanently change the color of STDOUT and STDERR.

Best Answer

STDOUT and STDERR don't have colors. What has color is your terminal (emulator); it has one foreground (and one background color) set at a time.

It should also be noted that STDOUT and STDERR are not singular -- they're per process output streams. There is no global STDOUT that applies to all programs. These streams are routed to your terminal, but they are distinct for each process.

Terminal emulators usually have ways to set the palette via a menu, such that the default foreground (applied to data received via both STDOUT and STDERR streams) could be whatever. You can also apply ANSI color codes in your prompt and if you don't reset the color with \[\033[0m\] at the end, it will continue to apply. Note that some applications use these and reset, so this is not a very ideal method, since the reset will go back to the terminal's default.

If setting the terminal foreground is not what you want, you can filter STDOUT/STDERR on a per process basis; see the suggestions here.

Related Question