Skip to content

Instantly share code, notes, and snippets.

@jhubert
Created February 24, 2013 17:53
Show Gist options
  • Save jhubert/5024807 to your computer and use it in GitHub Desktop.
Save jhubert/5024807 to your computer and use it in GitHub Desktop.
Generates a table of the `tput setaf` and `tput setab` colors in bash. Based on Daniel Crisman's script from the Bash Prompt HOWTO on Colours: http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
#!/bin/bash
T='gYw' # The test text
for FGs in 0 1 2 3 4 5 6 7;
do FG=${FGs// /}
echo -en " $FGs $(tput setaf $FG) $T "
for BG in 0 1 2 3 4 5 6 7;
do echo -en "$EINS $(tput setaf $FG)$(tput setab $BG) $T $(tput sgr0)";
done
echo;
echo -en "bold $FGs $(tput bold; tput setaf $FG) $T "
for BG in 0 1 2 3 4 5 6 7;
do echo -en "$EINS $(tput bold; tput setaf $FG)$(tput setab $BG) $T $(tput sgr0)";
done
echo;
done
Copy link

ghost commented Nov 13, 2013

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment