BHK Code Vault

Coloring terminal output

Terminal output is boringly just whatever text color you have set, but it can be set to a few default colors within a shell script. The trick is to add some variables before the echo statements and use inside them, like the example below. The actual color will depend on the theme, usually set from lxappearance.

#!/bin/bash

red=$'\e[1;31m'
grn=$'\e[1;32m'
yel=$'\e[1;33m'
blu=$'\e[1;34m'
mag=$'\e[1;35m'
cyn=$'\e[1;36m'
end=$'\e[0m'

echo "${yel}**************************"
echo "Install programs:"
echo "--------------------------${end}"
#code, #blog