From 2080d453714258e1403f16be7e55b4d150bcdcaa Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 22 Aug 2026 23:33:59 +0700 Subject: [PATCH] bash-colors: remove redundant 0 prefixes Leading 0 are stripped, and omitted numbers are automatically 0. --- .bin/bash-colors | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.bin/bash-colors b/.bin/bash-colors index ed61f8b..eaa1f25 100755 --- a/.bin/bash-colors +++ b/.bin/bash-colors @@ -1,5 +1,5 @@ #!/bin/bash -# Author: Mike Frysinger ; released into the public domain; suck it. +# Written by Mike Frysinger . Released into the public domain. # This is for bash. BASH_PREFIX="\e" @@ -10,12 +10,12 @@ PREFIX=${BASH_PREFIX} show_env() { local c colors=( - GOOD="\$'${PREFIX}[32;01m'" - WARN="\$'${PREFIX}[33;01m'" - BAD="\$'${PREFIX}[31;01m'" - HILITE="\$'${PREFIX}[36;01m'" - BRACKET="\$'${PREFIX}[34;01m'" - NORMAL="\$'${PREFIX}[0m'" + GOOD="\$'${PREFIX}[32;1m'" + WARN="\$'${PREFIX}[33;1m'" + BAD="\$'${PREFIX}[31;1m'" + HILITE="\$'${PREFIX}[36;1m'" + BRACKET="\$'${PREFIX}[34;1m'" + NORMAL="\$'${PREFIX}[m'" ) for c in "${colors[@]}" ; do [[ -t 0 ]] || c="${c%=*}=" @@ -34,7 +34,7 @@ check256() { showit() { local col="${PREFIX}[${1};${2}m" - printf '%bthis color is: %s %b\n' "${col}" "${col}" "${PREFIX}[0m" + printf '%bthis color is: %s %b\n' "${col}" "${col}" "${PREFIX}[m" } main() { @@ -56,13 +56,13 @@ main() { cube|6x6x6) check256 for n in {16..231} ; do - showit "38;05" $(printf '%03i' ${n}) + showit "38;5" $(printf '%03i' ${n}) done ;; gr[ae]y) check256 for n in {232..255} ; do - showit "38;05" ${n} + showit "38;5" ${n} done ;; all|256) -- 2.47.3