bin/colortest

59 lines
1.0 KiB
Plaintext
Raw Permalink Normal View History

2019-06-07 00:40:15 -05:00
#! /bin/bash
#
# colortest.bash
# A script to ricily display a color palette
# Copyright (C) 2019 Vintage Salt <rehashedsalt@cock.li>
#
# Distributed under terms of the MIT license.
#
# Globals
2019-06-07 00:50:08 -05:00
teststring="•••"
2019-06-07 00:40:15 -05:00
padding=" "
spacer=" "
# Derived globals
teststringlen="$(( $(wc -m <<< "$teststring") - 1 ))"
# $1: Foreground color
# $2: Background color
printc() {
[ -z "$1" ] && return 1
[ -z "$2" ] && return 2
printf "\e[0m\e[$2m\e[$1m$padding$teststring$padding\e[0m"
}
# $1: Heading
printh() {
[ -z "$1" ] && return 1
2019-06-07 00:41:15 -05:00
printf "$padding%${teststringlen}s$padding$spacer" "$1"
2019-06-07 00:40:15 -05:00
}
println() {
printf "\\n"
}
# Headers
printf "%8s$spacer"
printh "0m"
for (( bg=40; bg<=47; bg++)); do
printh "${bg}m"
done
println
# Content
for fg in $(seq 30 1 37) "" $(seq 90 1 97); do
[ -z "$fg" ] && println && continue
headerstring="${fg}m"
printf "%8s$spacer" "$headerstring"
# No background
printc $fg 0
printf "$spacer"
# All backgrounds
for (( bg=40; bg<=47; bg++)); do
printc $fg $bg
2019-06-07 00:40:15 -05:00
printf "$spacer"
done
println
2019-06-07 00:40:15 -05:00
done
println