From bea99abd8dc9b2459a6ba23396ee59f62293a79a Mon Sep 17 00:00:00 2001 From: WaLLy3K Date: Tue, 5 Sep 2017 23:28:33 +1000 Subject: [PATCH] Ensure colour consistency between terminal themes * Comment file for review-ability * Add BOLD and UNDERLINE options * Select most readable colours out of LIGHT/DARK options * Provide empty variables for `set -u` * Deprecate unnecessary variables * Correct colours for TICK/CROSS/DONE * Escape r twice and add ESC to OVER --- advanced/Scripts/COL_TABLE | 65 +++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/advanced/Scripts/COL_TABLE b/advanced/Scripts/COL_TABLE index 20dd98b0..57aab4dd 100644 --- a/advanced/Scripts/COL_TABLE +++ b/advanced/Scripts/COL_TABLE @@ -1,28 +1,49 @@ +# Determine if terminal is capable of showing colours if [[ -t 1 ]] && [[ $(tput colors) -ge 8 ]]; then + # Bold and underline may not show up on all clients + # If something MUST be emphasised, use both + COL_BOLD='' + COL_ULINE='' + COL_NC='' - COL_WHITE='' - COL_BLACK='' - COL_BLUE='' - COL_LIGHT_BLUE='' - COL_GREEN='' - COL_LIGHT_GREEN='' - COL_CYAN='' - COL_LIGHT_CYAN='' - COL_RED='' - COL_LIGHT_RED='' - COL_URG_RED='' - COL_PURPLE='' - COL_LIGHT_PURPLE='' - COL_BROWN='' - COL_YELLOW='' - COL_GRAY='' - COL_LIGHT_GRAY='' - COL_DARK_GRAY='' + COL_GRAY='' + COL_RED='' + COL_GREEN='' + COL_YELLOW='' + COL_BLUE='' + COL_PURPLE='' + COL_CYAN='' +else + # Provide empty variables for `set -u` + COL_BOLD="" + COL_ULINE="" + + COL_NC="" + COL_GRAY="" + COL_RED="" + COL_GREEN="" + COL_YELLOW="" + COL_BLUE="" + COL_PURPLE="" + COL_CYAN="" fi -TICK="[${COL_LIGHT_GREEN}✓${COL_NC}]" -CROSS="[${COL_LIGHT_RED}✗${COL_NC}]" +# Deprecated variables +COL_WHITE="${COL_BOLD}" +COL_BLACK="${COL_NC}" +COL_LIGHT_BLUE="${COL_BLUE}" +COL_LIGHT_GREEN="${COL_GREEN}" +COL_LIGHT_CYAN="${COL_CYAN}" +COL_LIGHT_RED="${COL_RED}" +COL_URG_RED="${COL_RED}${COL_BOLD}${COL_ULINE}" +COL_LIGHT_PURPLE="${COL_PURPLE}" +COL_BROWN="${COL_YELLOW}" +COL_LIGHT_GRAY="${COL_GRAY}" +COL_DARK_GRAY="${COL_GRAY}" + +TICK="[${COL_GREEN}✓${COL_NC}]" +CROSS="[${COL_RED}✗${COL_NC}]" INFO="[i]" QST="[?]" -DONE="${COL_LIGHT_GREEN} done!${COL_NC}" -OVER="\r\033[K" +DONE="${COL_GREEN} done!${COL_NC}" +OVER="\\r"