------------------------------------------------------------------------------- TTY graphics using tput This is actually not often needed a lot as almost all terminal graphics is now based on ANSI terminal codes, which you can hardcode. But if you want your script to be versatile... See my scripts "graphics_colors" and "graphics_256color" https://antofthy.gitlab.io/software/#graphics ------------------------------------------------------------------------------- Using tput tput bold # enter bold mode tput cup 5 23 # cursor to move to row 5 column 23 tput clear # clear screen tput lines # number of lines on screen (typical saved in $LINES) tput cols # number of columns (typical saved in $COLUMNS EG: 80) norm="$(tput sgr0)" bold="$(tput bold)" underline=$(tput sgr 0 1) red="$(tput setaf 1)" green="$(tput setaf 2)" yellow="$(tput setaf 3)" blue="$(tput setaf 4)" purple=$(tput setaf 171) # fails unless TERM=xterm-256color See terminfo(5) for more information # tabular assignment of colors and modes # as a accociative hash, or variables unset C; declare -A C while read var arg; do [[ -z $var ]] && continue [[ $var = '#' ]] && continue # argument is a number [[ $arg != [a-z]* ]] && arg="setaf $arg" # save as a associative hash array EG: ${C[cyan]} C[$var]=$(tput $arg) # save as as variable in capitals EG: $CYAN declare ${var^^}=$(tput $arg) done <<<' # text modes norm sgr0 bold bold rev rev uline smul # standard colors red 1 green 2 yellow 3 blue 4 purple 5 cyan 6 grey 8 # optional (bold color is same as bold bright-color) black 0 white 7 Bred 9 Bgreen 10 Byellow 11 Bblue 12 Bpurple 13 Bcyan 14 Bwhite 14 # xterm-256color seagreen 36 firebrick 52 hotpink 199 orange 202 ' # using the hash table echo ${C[red]}----${C[norm]} # using the variables that were set echo $ORANGE----$NORM #NOTE codes for a grayscale of 26 colors... # 0, 232 to 255, 15 -------------------------------------------------------------------------------