Skip to content

Instantly share code, notes, and snippets.

@robertpeteuil
Last active April 30, 2023 23:21
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 robertpeteuil/85795abae79b53aeece5b0e543acfa32 to your computer and use it in GitHub Desktop.
Save robertpeteuil/85795abae79b53aeece5b0e543acfa32 to your computer and use it in GitHub Desktop.
Bash Ansi Colors
#!/bin/bash
## Ansi Colors
N="$(printf '\033[')" x=30
for a in Bl R G Y B M C W # 4-bit Black Red Green Yellow Blue Magenta Cyan White
do eval $a='$N'"'"$(( x))"m'" \
b$a='$N'"'"$((60+x))"m'" \
${a}bg='$N'"'"$((10+x))"m'" \
b${a}bg='$N'"'"$((70+x))"m'" # bX=bright Xbg=background bXbg=brgt bgnd
x=$((x+1))
done
N="${N}0m"
printf "$Y${Gbg}I am yellow on green.$N\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment