Skip to content

Instantly share code, notes, and snippets.

@hypergig
Last active September 27, 2020 19:10
Show Gist options
  • Save hypergig/ea6a60469ab4075b2310b56fa27bae55 to your computer and use it in GitHub Desktop.
Save hypergig/ea6a60469ab4075b2310b56fa27bae55 to your computer and use it in GitHub Desktop.
Display all the terminal colors that can be seen over a white or black background
# taken from https://misc.flogisoft.com/bash/tip_colors_and_formatting#colors2
# with a blacklist of the hardest colors to see agaist a black or white background
blacklist=(0 1 7 9 11 {15..18} {154..161} {190..197} {226..235} {250..255})
#blacklist=()
colors=$(printf '%d\n' {0..255} ${blacklist[@]} | sort -n | uniq -u)
slot=0
for fgbg in 38 48 ; do # Foreground / Background
for color in $colors ; do # Colors
# Display the color
printf "\e[${fgbg};5;%sm %3s \e[0m" $color $color
# Display 6 colors per lines
if [ $((($slot + 1) % 6)) == 4 ] ; then
echo # New line
fi
slot=$((slot + 1))
done
echo # New line
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment