From ff23fd30750232a66defeb98d81f68e0a7e670c9 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Fri, 1 Oct 2021 04:02:49 -0700 Subject: [PATCH] add morecolors --- sh/morecolors | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 sh/morecolors diff --git a/sh/morecolors b/sh/morecolors new file mode 100644 index 0000000..cdd08bd --- /dev/null +++ b/sh/morecolors @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# YES_ZSH +# YES_BASH +# NO_DASH +# NO_ASH + +morecolors() { ### @- print all 256 colors that are available on most terminals. + # borrowed from leah2's dotfiles. + local i= + for i in {0..255}; do + printf '\e[48;5;%dm\e[38;5;15m %03d ' $i $i + printf '\e[33;5;0m\e[38;5;%dm %03d ' $i $i + [ "$(( i+1 <= 16 ? (i+1) % 8 : ( (i+1)-16) % 6 ))" = 0 ] && printf '\e[0m\n' + [ "$(( i+1 <= 16 ? (i+1) % 16 : ( (i+1)-16) % 36 ))" = 0 ] && printf '\e[0m\n' + done +} + +[ -n "${preload+-}" ] || morecolors "$@"