Created
March 3, 2023 02:03
-
-
Save allen0099/ae565411755468fbeda6e451cb18d495 to your computer and use it in GitHub Desktop.
Testing color scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Source: https://misc.flogisoft.com/bash/tip_colors_and_formatting | |
set -e | |
echo "=== 16 colors ===" | |
# Background | |
for clbg in {40..47} 49 {100..107}; do | |
# Foreground | |
for clfg in {30..38} 39 {90..97}; do | |
# Formatting | |
for attr in {0..8}; do | |
# Print the result | |
echo -en "\e[${attr};${clbg};${clfg}m \\\e[${attr};${clbg};${clfg}m \e[0m" | |
done | |
echo #Newline | |
done | |
done | |
echo "=== 256 colors ===" | |
for fgbg in 38 48; do # Foreground / Background | |
for color in {0..255}; do # Colors | |
# Display the color | |
printf "\e[${fgbg};5;${color}m \\\e[${fgbg};5;%3sm \e[0m" "$color" | |
# Display 6 colors per lines | |
if [ $(((color + 1) % 6)) == 4 ]; then | |
echo # New line | |
fi | |
done | |
echo # New line | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment