Skip to content

Instantly share code, notes, and snippets.

@brandon-wallace
Last active July 16, 2022 13:20
Show Gist options
  • Save brandon-wallace/db90e5084e70ff9e0fd028da9a2c7c96 to your computer and use it in GitHub Desktop.
Save brandon-wallace/db90e5084e70ff9e0fd028da9a2c7c96 to your computer and use it in GitHub Desktop.
Print Bash Foreground Colors
#!/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