diff --git a/bash/colorfade b/bash/colorfade index c8b2f64..4140c6f 100644 --- a/bash/colorfade +++ b/bash/colorfade @@ -1,5 +1,6 @@ #!/bin/bash +# Adapted from: # https://unix.stackexchange.com/a/269085 # A simple test of your console capacity to present so many colors is: @@ -8,6 +9,9 @@ # If that small change is visible, your console is capable of 16 million colors. # If your console type support this, this code will create a color table: +function ctrl_c() { printf '\e[m';printf '\n\e[0;38;2;255;0;0mExiting\e[m\n'; exit 0; } +trap ctrl_c int + mode2header(){ #### For 16 Million colors use \e[0;38;2;R;G;Bm each RGB is {0..255} printf '\e[m' # reset the colors. @@ -24,7 +28,7 @@ mode2colors(){ printf "%2x,%2x" "$r" "$g" for b in "${samples[@]}"; do # looks cooler if you replace the # with an ansi block character - ` # (but I don't feel like messing with the encoding on my git server) + # (but I don't feel like messing with the encoding on my git server) # https://theasciicode.com.ar/extended-ascii-code/block-graphic-character-ascii-code-219.html printf '\e[0;%s8;2;%s;%s;%sm#' "$fb" "$r" "$g" "$b" done; printf '\e[m\n' @@ -33,3 +37,5 @@ mode2colors(){ } mode2header mode2colors 3 + +printf '\n\e[0;38;2;255;0;0mNote\e[m: This is only a sample, all 16m colors should be available for use\e[m\n\n'