Bash Color script output (cross-platform)

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Remarks

tput queries the terminfo database for terminal-dependent information.

From tput on Wikipedia:

In computing, tput is a standard Unix operating system command which makes use of terminal capabilities.

Depending on the system, tput uses the terminfo or termcap database, as well as looking into the environment for the terminal type.

from Bash Prompt HOWTO: Chapter 6. ANSI Escape Sequences: Colours and Cursor Movement:

  • tput setab [1-7]

    • Set a background colour using ANSI escape
  • tput setb [1-7]

    • Set a background colour
  • tput setaf [1-7]

    • Set a foreground colour using ANSI escape
  • tput setf [1-7]

    • Set a foreground colour
  • tput bold

    • Set bold mode
  • tput sgr0

    • Turn off all attributes (doesn't work quite as expected)


Got any Bash Question?