How colorizing output is achieved on a linux console :
By sending ansi escape sequences to the tty driver. Just try :
echo -e "\e[31mThis is displayed in red\e[0m"
We then can understand it is up to the running program to decide what is to be printed in which color.
This escape sequence might be hardcoded : (Like if I had written the above line as part of some shell script) In which case you just cannot do much apart from either changing the source code or fiddling the terminal capabilities database which is tedious non portable work.
Note that most of these programs generally offer some optional parameter on the command line aiming at enabling/disabling colorized output. (see for example the --color option in grep.)
This escape sequence might depend on some user defined environment variable :
- Most shells will honor the PS1 environment variable for displaying the primary command prompt, variable that can contain ansi escape sequences.
- utilities like
ls can honor the LS_COLOUR environment variable for colorizing filenames depending on the type of the associated file.
This escape sequence might honor user settings as part of some dedicated and particular configuration file.
- Most used/known
vim editor would conform its output to definitions standing in the .vimrc a configuration file you would have to edit first.
- Other utilities like top (via
.toprc) also conform to some configuration file but enable its definitions to be set at runtime.
So… each to its own way, read the manual for each particular command and see what applies.