How to highlight your output in Bash

Even if you write your program with Bash, you have to think about the user. To improve the program interface, you can use special escape sequences to highlight output.

For example:

printf -- ' doing something... \n';
printf -- '\033[37m one more output \033[0m\n';
printf -- '\033[32m SUCCESS: yay \033[0m\n';
printf -- '\033[33m WARNING: hmm \033[0m\n';
printf -- '\033[31m ERROR: foobar \033[0m\n';
colors in bash
How it looks like in MacOS terminal

You can use escape sequences to highlight some of your output. Don’t forget to turn it back with “\033[0m”.

Also, not all terminals supports escape sequences check it out before use them.