-
-
Save pharaoh1/4853c9c1521721083a2ee939f6f10c15 to your computer and use it in GitHub Desktop.
Shows terminal 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 | |
n=32 | |
arg=setaf | |
text='Hello World! This is %s %d' | |
_help() | |
{ | |
printf 'usage: %s [--help|-H] [--16] [--256] [-t|--tiny] [--background|-b]\n' "$(basename $0)" | |
exit 0 | |
} | |
while (( $# > 0 )) | |
do | |
case "$1" in | |
256|--256|-256) | |
n=256 | |
shift | |
;; | |
16|--16|-16) | |
n=16 | |
shift | |
;; | |
--background|-b) | |
arg=setab | |
shift | |
;; | |
--tiny|-t) | |
text='█' | |
shift | |
;; | |
--help|-H) | |
_help | |
;; | |
--*|-*) | |
_help | |
;; | |
esac | |
done | |
for f in $(seq $n) | |
do | |
tput $arg $f | |
printf "$text" $arg $f | |
tput sgr0 | |
if (( f % 16 == 0 )) || [[ "$arg" == 'setab' ]] || [[ "$text" != '█' ]] | |
then | |
printf '\n' | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment