From 0d394dd5772aa6b741a47143309922cf60eaaff7 Mon Sep 17 00:00:00 2001 From: Tomas Mirchev Date: Mon, 20 Oct 2025 20:21:35 +0300 Subject: [PATCH] add new bins --- config/shared/bin/print-underline.sh | 7 ++ config/shared/bin/test-true-color.sh | 117 +++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100755 config/shared/bin/print-underline.sh create mode 100644 config/shared/bin/test-true-color.sh diff --git a/config/shared/bin/print-underline.sh b/config/shared/bin/print-underline.sh new file mode 100755 index 0000000..d425d17 --- /dev/null +++ b/config/shared/bin/print-underline.sh @@ -0,0 +1,7 @@ +# tempfile=$(mktemp) \ +# && curl -o $tempfile https://raw.githubusercontent.com/wezterm/wezterm/master/termwiz/data/wezterm.terminfo \ +# && tic -x -o ~/.terminfo $tempfile \ +# && rm $tempfile + +printf "\x1b[58:2::255:0:0m\x1b[4:1msingle\x1b[4:2mdouble\x1b[4:3mcurly\x1b[4:4mdotted\x1b[4:5mdashed\x1b[0m\n" + diff --git a/config/shared/bin/test-true-color.sh b/config/shared/bin/test-true-color.sh new file mode 100644 index 0000000..681285c --- /dev/null +++ b/config/shared/bin/test-true-color.sh @@ -0,0 +1,117 @@ +#!/bin/bash +# +# This file echoes a bunch of 24-bit color codes +# to the terminal to demonstrate its functionality. +# The foreground escape sequence is ^[38;2;;;m +# The background escape sequence is ^[48;2;;;m +# range from 0 to 255 inclusive. +# The escape sequence ^[0m returns output to default + +setBackgroundColor() +{ + echo -en "\x1b[48;2;$1;$2;$3""m" +} + +resetOutput() +{ + echo -en "\x1b[0m\n" +} + +# Gives a color $1/255 % along HSV +# Who knows what happens when $1 is outside 0-255 +# Echoes "$red $green $blue" where +# $red $green and $blue are integers +# ranging between 0 and 255 inclusive +rainbowColor() +{ + let h=$1/43 + let f=$1-43*$h + let t=$f*255/43 + let q=255-t + + if [ $h -eq 0 ] + then + echo "255 $t 0" + elif [ $h -eq 1 ] + then + echo "$q 255 0" + elif [ $h -eq 2 ] + then + echo "0 255 $t" + elif [ $h -eq 3 ] + then + echo "0 $q 255" + elif [ $h -eq 4 ] + then + echo "$t 0 255" + elif [ $h -eq 5 ] + then + echo "255 0 $q" + else + # execution should never reach here + echo "0 0 0" + fi +} + +for i in `seq 0 127`; do + setBackgroundColor $i 0 0 + echo -en " " +done +resetOutput +for i in `seq 255 128`; do + setBackgroundColor $i 0 0 + echo -en " " +done +resetOutput + +for i in `seq 0 127`; do + setBackgroundColor 0 $i 0 + echo -n " " +done +resetOutput +for i in `seq 255 128`; do + setBackgroundColor 0 $i 0 + echo -n " " +done +resetOutput + +for i in `seq 0 127`; do + setBackgroundColor 0 0 $i + echo -n " " +done +resetOutput +for i in `seq 255 128`; do + setBackgroundColor 0 0 $i + echo -n " " +done +resetOutput + +for i in `seq 0 127`; do + setBackgroundColor `rainbowColor $i` + echo -n " " +done +resetOutput +for i in `seq 255 128`; do + setBackgroundColor `rainbowColor $i` + echo -n " " +done +resetOutput + +echo -e "Another test:" +awk 'BEGIN{ + s="/\\/\\/\\/\\/"; + for (colnum = 0; colnum < 77; colnum++) { + r = 255-(colnum*255/76); + g = (colnum*510/76); + b = (colnum*255/76); + if (g>255) g = 510-g; + printf "\033[48;2;%d;%d;%dm", r,g,b; + printf "%s\033[0m", substr(s,(colnum%4)+1,1); + } + printf "\n"; +}' + +echo -e "\nTerm: $(echo "$TERM")" +echo "$(tmux info | grep -e RGB -e Tc)" +echo -e "\nTmux server options:\n$(tmux show-options -s | grep terminal)" +echo ""