Coloured text in MATE terminal?

Is there any way to send codes to colourize text in the MATE terminal?
For example, I might want to highlight only the word 'good' in the following sentence, by sending a code before and after 'good'..
"That was good work."
I know it can be done on a number of terminals (VT100, is one).

Yes, there are several ways:

  1. You can use ANSI escape codes directly
    ( )

  2. You can also use the terminfo utility from the commandline or from a shellscript by using the command tput ( see man tput )
    Below is an overview of some colorcapabilities of tput:

Foreground color

tput setaf 0	# black
tput setaf 1	# red
tput setaf 2	# Green
tput setaf 3	# yellow
tput setaf 4	# blue
tput setaf 5	# magenta
tput setaf 6	# cyan
tput setaf 7	# white

background color

tput setab 0	# black
tput setab 1	# red
tput setab 2	# Green
tput setab 3	# yellow
tput setab 4	# blue
tput setab 5	# magenta
tput setab 6	# cyan
tput setab 7	# white

character attributes

tput bold	# bold
tput dim	# half-bright
tput sgr0	# reset to normal
tput smul	# begin underline
tput rmul	# end underline
tput rev	# reverse
tput smso	# begin standout mode (bold on rxvt)
tput rmso	# end standout mode

So you can do:

echo "That was $(tput bold)good $(tput sgr0) work."

But if you want to use it a lot , it is ofcourse highly inefficient to call tput again and again.
To optimize that I always use it like this:

B=$(tput bold)
N=$(tput sgr0)

echo "That was ${B}good${N} work."

in ANSI:

echo -e "That was\033[1m good \033[mwork."

With ANSI escape codes you can use full 8-bit per color on mate-terminal although it is beyond the capabilities of some other terminals.

try this script:


for red in {0..255..5}
	for green in {0..255..5}
		for blue in {0..255..5}
			echo -ne "\033[38;2;${red};${green};${blue}mX\033[0m"