Linux tip: Coloring terminal output

Coloring output by using escape sequences is a technique I've known before I started using Linux. That's about two decades now.

But, as I learned today, the tput command provides a much more versatile approach:

bold=$(tput bold)
normal=$(tput sgr0)
echo This is ${bold}bold${normal} and this is not.

tput uses information about the actual terminal to generate the right escape sequences, so it's much better to use tput than to hardcode those.

If you have any questions or would like to discuss a topic, tweet me @geewiz or join the chat on my Discord server!