#!/bin/bash # this is a program to demonstrate changing the color of the text in an xterm printf 'You want to echo -e or printf the string "\\033[CmA Message\\033[0m".\n' printf "Where C is the set of numbers in ()\'s. The color can be set using\n" printf "one two or three arguments separated by ;'s.\n\n" printf ' \033[0mNormal\033[0m (0) ' printf ' \033[1mBold\033[0m (1) ' printf ' \033[4mUnderlined\033[0m (4) ' printf ' \033[5mBlink\033[0m (5) ' printf ' \033[7mInverse\033[0m (7)\n' showcolor() { printf "%-16s" "$1" color=$2 for mode in 0 1 4 5 7 8 do printf '\033[%d;%dm(%d;%d)\033[0m\t' $mode $color $mode $color done printf '\n' } printf '\n' showcolor "Black" 30 showcolor "Red" 31 showcolor "Green" 32 showcolor "Yellow" 33 showcolor "Blue" 34 showcolor "Magenta" 35 showcolor "Cyan" 36 showcolor "Light Gray" 37 showcolor "Default" 38 color=(Black Red Green Yellow Blue Magenta Cyan Gray Default) for mode in 0 1 4 5 7 do printf '\n' for c in "" ${color[*]} do printf "%-11s" $c done printf '\n' for fg in 0 1 2 3 4 5 6 7 8 do printf "%-11s" ${color[$fg]} for bg in 0 1 2 3 4 5 6 7 8 do printf '\033[%d;3%d;4%dm(%d;3%d;4%d)\033[0m ' $mode $fg $bg $mode $fg $bg done printf '\n' done done