From e2f7ec492f10d5a74c8864eb3161d8d244bd7bd0 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Thu, 30 Jul 2026 01:21:34 -0400 Subject: [PATCH] Color swatches mode for `__build_sgr_code` --- bin/__build_sgr_code | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/bin/__build_sgr_code b/bin/__build_sgr_code index 60ed83f..fc994dd 100755 --- a/bin/__build_sgr_code +++ b/bin/__build_sgr_code @@ -194,6 +194,21 @@ color_chart() greyscale_chart } +color_block() +{ + printf "\e[37;1;48;5;${1}m%3i\e[m " ${1} +} + +color_swatches() +{ + while [ "$1" != "" ] + do + color_block $1 + shift 1 + done + printf "\n" +} + setup_color_depth() { use_8_bit=0 @@ -544,11 +559,18 @@ build_sgr_code() } output="" -while [ ! -z $1 ] -do - build_sgr_code $1 - shift 1 -done + +if [ "$1" = "color-swatches" ] +then + shift 1 + color_swatches $* +else + while [ ! -z "$1" ] + do + build_sgr_code $1 + shift 1 + done +fi if [ ! -z "${output}" ] && [ ${nocsi} -ne 1 ] then