Skip to content

Instantly share code, notes, and snippets.

@nemoDreamer
Created August 28, 2023 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nemoDreamer/e2ae7453cb25797e478c04b2b3b93214 to your computer and use it in GitHub Desktop.
Save nemoDreamer/e2ae7453cb25797e478c04b2b3b93214 to your computer and use it in GitHub Desktop.
Display ANSI palette in terminal
#!/usr/bin/env bash
NAMES=(Black Red Green Yellow Blue Magenta Cyan White)
CHAR="██ "
for i in {0..7}; do
CODE=$((i + 30))
BRIGHT=$((i + 90))
echo -n -e "${NAMES[$i]}\t"
# blocks
# - bright
echo -n -e "\033[${BRIGHT}m${CHAR}"
# - normal
echo -n -e "\033[${CODE}m${CHAR}"
# - faded
echo -n -e "\033[$CODE;2m${CHAR}"
# reset
echo -e "\033[0m\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment