From bc8d1808fb1e5e47621af67911b50801e80c4195 Mon Sep 17 00:00:00 2001 From: Andre Ramnitz Date: Fri, 6 Sep 2024 00:37:12 +0200 Subject: [PATCH] scripts: clean-up color scripts --- local/dot-local/bin/colors | 192 +++++++++++++++++++++++++------------ local/dot-local/bin/colr | 132 ------------------------- 2 files changed, 130 insertions(+), 194 deletions(-) delete mode 100755 local/dot-local/bin/colr diff --git a/local/dot-local/bin/colors b/local/dot-local/bin/colors index b6b71325..32ab4a4d 100755 --- a/local/dot-local/bin/colors +++ b/local/dot-local/bin/colors @@ -1,62 +1,130 @@ -#! /bin/bash -set -e - - -mainFunction () { - echo - printColors - printGuidelines -} - - -printColor () { - local color="${1}" - - printf "\033[1;4%sm " "${color}" - printf "\033[0m " - printf "\033[1;3%smSampleText " "${color}" - printf "\033[0;3%smSampleText " "${color}" - printf "\033[0m\n" -} - - -printColors () { - local color - # 0 black - # 1 red - # 2 green - # 3 yellow - # 4 blue - # 5 magenta / orange - # 6 cyan / purple - # 7 white - - for color in 0 7; do - printColor "${color}" - done - echo - - for color in 4 5 6; do - printColor "${color}" - done - echo - - for color in 2 3 1; do - printColor "${color}" - done - echo -} - - -printGuidelines () { - echo "A good palette has:" - echo "- All colors easy to read." - echo "- Similar eye catchiness within the same group, except for monochromes." - echo "- Similar or greater eye catchiness in upper groups, including this text." - echo "- Similar color within the same line." - echo "- The last group as: green yellow red." - echo -} - - -mainFunction +#!/bin/bash + +case $1 in + 1) + set -e + mainFunction () { + echo + printColors + printGuidelines + } + + + printColor () { + local color="${1}" + + printf "\033[1;4%sm " "${color}" + printf "\033[0m " + printf "\033[1;3%smSampleText " "${color}" + printf "\033[0;3%smSampleText " "${color}" + printf "\033[0m\n" + } + + + printColors () { + local color + # 0 black + # 1 red + # 2 green + # 3 yellow + # 4 blue + # 5 magenta / orange + # 6 cyan / purple + # 7 white + + for color in 0 7; do + printColor "${color}" + done + echo + + for color in 4 5 6; do + printColor "${color}" + done + echo + + for color in 2 3 1; do + printColor "${color}" + done + echo + } + + + printGuidelines () { + echo "A good palette has:" + echo "- All colors easy to read." + echo "- Similar eye catchiness within the same group, except for monochromes." + echo "- Similar or greater eye catchiness in upper groups, including this text." + echo "- Similar color within the same line." + echo "- The last group as: green yellow red." + echo + } + + + mainFunction;; + + 2) + echo -e "\033[0mNC (No color)" + echo -e "\033[1;37mWHITE\t\033[0;30mBLACK" + echo -e "\033[0;34mBLUE\t\033[1;34mLIGHT_BLUE" + echo -e "\033[0;32mGREEN\t\033[1;32mLIGHT_GREEN" + echo -e "\033[0;36mCYAN\t\033[1;36mLIGHT_CYAN" + echo -e "\033[0;31mRED\t\033[1;31mLIGHT_RED" + echo -e "\033[0;35mPURPLE\t\033[1;35mLIGHT_PURPLE" + echo -e "\033[0;33mYELLOW\t\033[1;33mLIGHT_YELLOW" + echo -e "\033[1;30mGRAY\t\033[0;37mLIGHT_GRAY";; + 3) + # Description: + # + # Prints a color table of 8bg * 8fg * 2 states (regular/bold) + # + # Copyright: + # + # (C) 2009 Wolfgang Frisch + # + # License: + # + # This program is free software: you can redistribute it and/or modify + # it under the terms of the GNU General Public License as published by + # the Free Software Foundation, either version 3 of the License, or + # (at your option) any later version. + # + # This program is distributed in the hope that it will be useful, + # but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + # GNU General Public License for more details. + # + # You should have received a copy of the GNU General Public License + # along with this program. If not, see . + + echo + echo Table for 16-color terminal escape sequences. + echo Replace ESC with \\033 in bash. + echo + echo "Background | Foreground colors" + echo "---------------------------------------------------------------------" + for((bg=40;bg<=47;bg++)); do + for((bold=0;bold<=1;bold++)) do + echo -en "\033[0m"" ESC[${bg}m | " + for((fg=30;fg<=37;fg++)); do + if [ $bold == "0" ]; then + echo -en "\033[${bg}m\033[${fg}m [${fg}m " + else + echo -en "\033[${bg}m\033[1;${fg}m [1;${fg}m" + fi + done + echo -e "\033[0m" + done + echo "--------------------------------------------------------------------- " + done + + echo + echo;; + 4) + for colour in {1..225} + do echo -en "\033[38;5;${colour}m38;5;${colour} \n" + done | column -x;; + *) + colors 1 + echo "Enter a number [1-4] to specify, which demo to run.";; +esac + diff --git a/local/dot-local/bin/colr b/local/dot-local/bin/colr deleted file mode 100755 index 90c0b059..00000000 --- a/local/dot-local/bin/colr +++ /dev/null @@ -1,132 +0,0 @@ -#!/bin/bash - -case $1 in - 1) - set -e - - - mainFunction () { - echo - printColors - printGuidelines - } - - - printColor () { - local color="${1}" - - printf "\033[1;4%sm " "${color}" - printf "\033[0m " - printf "\033[1;3%smSampleText " "${color}" - printf "\033[0;3%smSampleText " "${color}" - printf "\033[0m\n" - } - - - printColors () { - local color - # 0 black - # 1 red - # 2 green - # 3 yellow - # 4 blue - # 5 magenta / orange - # 6 cyan / purple - # 7 white - - for color in 0 7; do - printColor "${color}" - done - echo - - for color in 4 5 6; do - printColor "${color}" - done - echo - - for color in 2 3 1; do - printColor "${color}" - done - echo - } - - - printGuidelines () { - echo "A good palette has:" - echo "- All colors easy to read." - echo "- Similar eye catchiness within the same group, except for monochromes." - echo "- Similar or greater eye catchiness in upper groups, including this text." - echo "- Similar color within the same line." - echo "- The last group as: green yellow red." - echo - } - - - mainFunction;; - - 2) - echo -e "\033[0mNC (No color)" - echo -e "\033[1;37mWHITE\t\033[0;30mBLACK" - echo -e "\033[0;34mBLUE\t\033[1;34mLIGHT_BLUE" - echo -e "\033[0;32mGREEN\t\033[1;32mLIGHT_GREEN" - echo -e "\033[0;36mCYAN\t\033[1;36mLIGHT_CYAN" - echo -e "\033[0;31mRED\t\033[1;31mLIGHT_RED" - echo -e "\033[0;35mPURPLE\t\033[1;35mLIGHT_PURPLE" - echo -e "\033[0;33mYELLOW\t\033[1;33mLIGHT_YELLOW" - echo -e "\033[1;30mGRAY\t\033[0;37mLIGHT_GRAY";; - 3) - # Description: - # - # Prints a color table of 8bg * 8fg * 2 states (regular/bold) - # - # Copyright: - # - # (C) 2009 Wolfgang Frisch - # - # License: - # - # This program is free software: you can redistribute it and/or modify - # it under the terms of the GNU General Public License as published by - # the Free Software Foundation, either version 3 of the License, or - # (at your option) any later version. - # - # This program is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - # GNU General Public License for more details. - # - # You should have received a copy of the GNU General Public License - # along with this program. If not, see . - - echo - echo Table for 16-color terminal escape sequences. - echo Replace ESC with \\033 in bash. - echo - echo "Background | Foreground colors" - echo "---------------------------------------------------------------------" - for((bg=40;bg<=47;bg++)); do - for((bold=0;bold<=1;bold++)) do - echo -en "\033[0m"" ESC[${bg}m | " - for((fg=30;fg<=37;fg++)); do - if [ $bold == "0" ]; then - echo -en "\033[${bg}m\033[${fg}m [${fg}m " - else - echo -en "\033[${bg}m\033[1;${fg}m [1;${fg}m" - fi - done - echo -e "\033[0m" - done - echo "--------------------------------------------------------------------- " - done - - echo - echo;; - 4) - for colour in {1..225} - do echo -en "\033[38;5;${colour}m38;5;${colour} \n" - done | column -x;; - *) - colr 1 - echo "Enter a number [1-4] to specify, which demo to run.";; -esac - -- 2.51.2