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' printf "%sn" "Text in ${red}red${end}, white and ${blu}blue${end}." shw_grey () { echo $(tput bold)$(tput setaf 0) $@ $(tput sgr 0) } shw_norm () { echo $(tput bold)$(tput setaf 9) $@ $(tput sgr 0) } shw_info () { echo $(tput bold)$(tput setaf 4) $@ $(tput sgr 0) } shw_warn () { echo $(tput bold)$(tput setaf 2) $@ $(tput sgr 0) } shw_err () { echo $(tput bold)$(tput setaf 1) $@ $(tput sgr 0) } print red; echo -e "e[31mfooe[m" autoload -U colors colors echo $fg[green]YES$fg[default] or $fg[red]NO$fg[default]? #!/bin/bash red='e[1;31m%se[0mn' green='e[1;32m%se[0mn' yellow='e[1;33m%se[0mn' blue='e[1;34m%se[0mn' magenta='e[1;35m%se[0mn' cyan='e[1;36m%se[0mn' printf "$green" "This is a test in green" printf "$red" "This is a test in red" printf "$yellow" "This is a test in yellow" printf "$blue" "This is a test in blue" printf "$magenta" "This is a test in magenta" printf "$cyan" "This is a test in cyan" var_color_black=0 var_color_red=1 var_color_green=2 var_color_yellow=3 var_color_blue=4 var_color_magenta=5 var_color_cyan=6 var_color_white=7 function colorBlue(){ tput setaf $var_color_blue; # tput setab $var_color_white; # Uncomment for white background } function resetColor(){ echo $(tput sgr0) ; } colorPath ; echo -n "hello world" ; # -n because resetColor echoes a newline resetColor ;