Skip to content

Instantly share code, notes, and snippets.

@ironpinguin
Created February 22, 2018 01:23
Show Gist options
  • Save ironpinguin/0b7cf6965f4b78bbec97dd1516f6e85c to your computer and use it in GitHub Desktop.
Save ironpinguin/0b7cf6965f4b78bbec97dd1516f6e85c to your computer and use it in GitHub Desktop.
Test the console Colors
#!/usr/bin/env bash
fontColor=38
backgroundColor=48
colortable() {
base=$1
count=0
for colorCode in `seq -w 0 255`; do
count=$(($count + 1))
echo -e -n "\033[${base};5;${colorCode}mCode ${colorCode} \033[0m"
if [[ $count -gt 7 ]]; then
echo
count=0
fi
done
echo
}
colorrun() {
base=$1
text=$2
textLength=${#text}
for colorCode in `seq -w 0 255`; do
echo -e -n "\033[${base};5;${colorCode}m${text}\033[0m\033[${textLength}D"
sleep 0.05
done
echo
}
rgbColor() {
base=$1
count=0
for rc in `seq -w 0 255`; do
for gc in `seq -w 0 255`; do
for bc in `seq -w 0 255`; do
count=$(($count + 1))
echo -e -n "\033[${base};2;${rc};${gc};${bc}mRGB $rc:$gc:$bc \033[0m"
if [[ $count -gt 10 ]]; then
echo
count=0
fi
done
done
done
echo
}
colortable $fontColor
colortable $backgroundColor
colorrun $fontColor "Hallo mein Freund"
colorrun $backgroundColor "Hallo mein Freund"
rgbColor $fontColor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment