DEV Community

Discussion on: Adding colors to Bash scripts

Collapse
 
moopet profile image
Ben Sinclair

Using escape codes directly is cool, but I'm a fan of using tput like this:

# SET Attribute Foreground <colour 123>
kindalightblue=$(tput setaf 123)
Enter fullscreen mode Exit fullscreen mode

There are a lot of handy things tput can do, and though the capabilities vary with your terminal, and though it's not completely portable either, you get all the colours your terminal can show.

Collapse
 
ifenna__ profile image
Ifenna • Edited

I haven't heard about tput before. I'll definitely check it out.

EDIT: Just took a look. It's great. Thanks for the tip 🚀.