Last active
July 16, 2022 13:20
-
-
Save brandon-wallace/db90e5084e70ff9e0fd028da9a2c7c96 to your computer and use it in GitHub Desktop.
Print Bash Foreground Colors
This file contains 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
#!/bin/bash | |
# Print a range of Bash foreground colors. | |
c1=0 | |
c2=30 | |
# The first color is black. This will set the background to white. | |
c3=';47' | |
for i in {0..15}; do | |
if [ $i -eq 8 ]; then | |
c1=1 | |
c2=30 | |
fi | |
echo -e "\033[${c1};${c2}${c3}m" 'Color => \\033['"${c1}"';'"${c2}m" "\033[0m" | |
c2=$((c2+1)); | |
# Remove the white background color. | |
[ $i -gt -1 ] && c3='' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment