Diff
1diff --git a/tools/install.sh b/tools/install.sh
2index 731d89a2997a23669b72d0c0fa11174117a6f59e..5009bd586b60eaae495b526aae123fa64499018b 100755
3--- a/tools/install.sh
4+++ b/tools/install.sh
5@@ -127,6 +127,24 @@ supports_hyperlinks() {
6 return 1
7 }
8
9+# Adapted from code and information by Anton Kochkov (@XVilka)
10+# Source: https://gist.github.com/XVilka/8346728
11+supports_truecolor() {
12+ case "$COLORTERM" in
13+ truecolor|24bit) return 0 ;;
14+ esac
15+
16+ case "$TERM" in
17+ iterm |\
18+ tmux-truecolor |\
19+ linux-truecolor |\
20+ xterm-truecolor |\
21+ screen-truecolor) return 0 ;;
22+ esac
23+
24+ return 1
25+}
26+
27 fmt_link() {
28 # $1: text, $2: url, $3: fallback mode
29 if supports_hyperlinks; then
30@@ -155,7 +173,28 @@ fmt_error() {
31
32 setup_color() {
33 # Only use colors if connected to a terminal
34- if is_tty; then
35+ if ! is_tty; then
36+ RAINBOW=""
37+ RED=""
38+ GREEN=""
39+ YELLOW=""
40+ BLUE=""
41+ BOLD=""
42+ RESET=""
43+ return
44+ fi
45+
46+ if supports_truecolor; then
47+ RAINBOW="
48+ $(printf '\033[38;2;255;0;0m')
49+ $(printf '\033[38;2;255;97;0m')
50+ $(printf '\033[38;2;247;255;0m')
51+ $(printf '\033[38;2;0;255;30m')
52+ $(printf '\033[38;2;77;0;255m')
53+ $(printf '\033[38;2;168;0;255m')
54+ $(printf '\033[38;2;245;0;172m')
55+ "
56+ else
57 RAINBOW="
58 $(printf '\033[38;5;196m')
59 $(printf '\033[38;5;202m')
60@@ -165,21 +204,14 @@ setup_color() {
61 $(printf '\033[38;5;093m')
62 $(printf '\033[38;5;163m')
63 "
64- RED=$(printf '\033[31m')
65- GREEN=$(printf '\033[32m')
66- YELLOW=$(printf '\033[33m')
67- BLUE=$(printf '\033[34m')
68- BOLD=$(printf '\033[1m')
69- RESET=$(printf '\033[m')
70- else
71- RAINBOW=""
72- RED=""
73- GREEN=""
74- YELLOW=""
75- BLUE=""
76- BOLD=""
77- RESET=""
78 fi
79+
80+ RED=$(printf '\033[31m')
81+ GREEN=$(printf '\033[32m')
82+ YELLOW=$(printf '\033[33m')
83+ BLUE=$(printf '\033[34m')
84+ BOLD=$(printf '\033[1m')
85+ RESET=$(printf '\033[0m')
86 }
87
88 setup_ohmyzsh() {
89diff --git a/tools/upgrade.sh b/tools/upgrade.sh
90index 994ffe9c9ca27ea2f5d9003baec2aee37265ad1d..25381de7e52c1c89fda550348e79f271c455ae10 100755
91--- a/tools/upgrade.sh
92+++ b/tools/upgrade.sh
93@@ -86,6 +86,24 @@ supports_hyperlinks() {
94 return 1
95 }
96
97+# Adapted from code and information by Anton Kochkov (@XVilka)
98+# Source: https://gist.github.com/XVilka/8346728
99+supports_truecolor() {
100+ case "$COLORTERM" in
101+ truecolor|24bit) return 0 ;;
102+ esac
103+
104+ case "$TERM" in
105+ iterm |\
106+ tmux-truecolor |\
107+ linux-truecolor |\
108+ xterm-truecolor |\
109+ screen-truecolor) return 0 ;;
110+ esac
111+
112+ return 1
113+}
114+
115 fmt_link() {
116 # $1: text, $2: url, $3: fallback mode
117 if supports_hyperlinks; then
118@@ -107,15 +125,27 @@ setopt typeset_silent
119 typeset -a RAINBOW
120
121 if is_tty; then
122- RAINBOW=(
123- "$(printf '\033[38;5;196m')"
124- "$(printf '\033[38;5;202m')"
125- "$(printf '\033[38;5;226m')"
126- "$(printf '\033[38;5;082m')"
127- "$(printf '\033[38;5;021m')"
128- "$(printf '\033[38;5;093m')"
129- "$(printf '\033[38;5;163m')"
130- )
131+ if supports_truecolor; then
132+ RAINBOW=(
133+ "$(printf '\033[38;2;255;0;0m')"
134+ "$(printf '\033[38;2;255;97;0m')"
135+ "$(printf '\033[38;2;247;255;0m')"
136+ "$(printf '\033[38;2;0;255;30m')"
137+ "$(printf '\033[38;2;77;0;255m')"
138+ "$(printf '\033[38;2;168;0;255m')"
139+ "$(printf '\033[38;2;245;0;172m')"
140+ )
141+ else
142+ RAINBOW=(
143+ "$(printf '\033[38;5;196m')"
144+ "$(printf '\033[38;5;202m')"
145+ "$(printf '\033[38;5;226m')"
146+ "$(printf '\033[38;5;082m')"
147+ "$(printf '\033[38;5;021m')"
148+ "$(printf '\033[38;5;093m')"
149+ "$(printf '\033[38;5;163m')"
150+ )
151+ fi
152
153 RED=$(printf '\033[31m')
154 GREEN=$(printf '\033[32m')