mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-19 20:29:45 +01:00
style: use 24bit colors in Oh My Zsh logo if supported
This commit is contained in:
parent
a92ee838f3
commit
fbdc078fa6
2 changed files with 86 additions and 24 deletions
|
@ -127,6 +127,24 @@ supports_hyperlinks() {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Adapted from code and information by Anton Kochkov (@XVilka)
|
||||||
|
# Source: https://gist.github.com/XVilka/8346728
|
||||||
|
supports_truecolor() {
|
||||||
|
case "$COLORTERM" in
|
||||||
|
truecolor|24bit) return 0 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$TERM" in
|
||||||
|
iterm |\
|
||||||
|
tmux-truecolor |\
|
||||||
|
linux-truecolor |\
|
||||||
|
xterm-truecolor |\
|
||||||
|
screen-truecolor) return 0 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
fmt_link() {
|
fmt_link() {
|
||||||
# $1: text, $2: url, $3: fallback mode
|
# $1: text, $2: url, $3: fallback mode
|
||||||
if supports_hyperlinks; then
|
if supports_hyperlinks; then
|
||||||
|
@ -155,7 +173,28 @@ fmt_error() {
|
||||||
|
|
||||||
setup_color() {
|
setup_color() {
|
||||||
# Only use colors if connected to a terminal
|
# Only use colors if connected to a terminal
|
||||||
if is_tty; then
|
if ! is_tty; then
|
||||||
|
RAINBOW=""
|
||||||
|
RED=""
|
||||||
|
GREEN=""
|
||||||
|
YELLOW=""
|
||||||
|
BLUE=""
|
||||||
|
BOLD=""
|
||||||
|
RESET=""
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if supports_truecolor; then
|
||||||
|
RAINBOW="
|
||||||
|
$(printf '\033[38;2;255;0;0m')
|
||||||
|
$(printf '\033[38;2;255;97;0m')
|
||||||
|
$(printf '\033[38;2;247;255;0m')
|
||||||
|
$(printf '\033[38;2;0;255;30m')
|
||||||
|
$(printf '\033[38;2;77;0;255m')
|
||||||
|
$(printf '\033[38;2;168;0;255m')
|
||||||
|
$(printf '\033[38;2;245;0;172m')
|
||||||
|
"
|
||||||
|
else
|
||||||
RAINBOW="
|
RAINBOW="
|
||||||
$(printf '\033[38;5;196m')
|
$(printf '\033[38;5;196m')
|
||||||
$(printf '\033[38;5;202m')
|
$(printf '\033[38;5;202m')
|
||||||
|
@ -165,21 +204,14 @@ setup_color() {
|
||||||
$(printf '\033[38;5;093m')
|
$(printf '\033[38;5;093m')
|
||||||
$(printf '\033[38;5;163m')
|
$(printf '\033[38;5;163m')
|
||||||
"
|
"
|
||||||
|
fi
|
||||||
|
|
||||||
RED=$(printf '\033[31m')
|
RED=$(printf '\033[31m')
|
||||||
GREEN=$(printf '\033[32m')
|
GREEN=$(printf '\033[32m')
|
||||||
YELLOW=$(printf '\033[33m')
|
YELLOW=$(printf '\033[33m')
|
||||||
BLUE=$(printf '\033[34m')
|
BLUE=$(printf '\033[34m')
|
||||||
BOLD=$(printf '\033[1m')
|
BOLD=$(printf '\033[1m')
|
||||||
RESET=$(printf '\033[m')
|
RESET=$(printf '\033[0m')
|
||||||
else
|
|
||||||
RAINBOW=""
|
|
||||||
RED=""
|
|
||||||
GREEN=""
|
|
||||||
YELLOW=""
|
|
||||||
BLUE=""
|
|
||||||
BOLD=""
|
|
||||||
RESET=""
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_ohmyzsh() {
|
setup_ohmyzsh() {
|
||||||
|
|
|
@ -86,6 +86,24 @@ supports_hyperlinks() {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Adapted from code and information by Anton Kochkov (@XVilka)
|
||||||
|
# Source: https://gist.github.com/XVilka/8346728
|
||||||
|
supports_truecolor() {
|
||||||
|
case "$COLORTERM" in
|
||||||
|
truecolor|24bit) return 0 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$TERM" in
|
||||||
|
iterm |\
|
||||||
|
tmux-truecolor |\
|
||||||
|
linux-truecolor |\
|
||||||
|
xterm-truecolor |\
|
||||||
|
screen-truecolor) return 0 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
fmt_link() {
|
fmt_link() {
|
||||||
# $1: text, $2: url, $3: fallback mode
|
# $1: text, $2: url, $3: fallback mode
|
||||||
if supports_hyperlinks; then
|
if supports_hyperlinks; then
|
||||||
|
@ -107,6 +125,17 @@ setopt typeset_silent
|
||||||
typeset -a RAINBOW
|
typeset -a RAINBOW
|
||||||
|
|
||||||
if is_tty; then
|
if is_tty; then
|
||||||
|
if supports_truecolor; then
|
||||||
|
RAINBOW=(
|
||||||
|
"$(printf '\033[38;2;255;0;0m')"
|
||||||
|
"$(printf '\033[38;2;255;97;0m')"
|
||||||
|
"$(printf '\033[38;2;247;255;0m')"
|
||||||
|
"$(printf '\033[38;2;0;255;30m')"
|
||||||
|
"$(printf '\033[38;2;77;0;255m')"
|
||||||
|
"$(printf '\033[38;2;168;0;255m')"
|
||||||
|
"$(printf '\033[38;2;245;0;172m')"
|
||||||
|
)
|
||||||
|
else
|
||||||
RAINBOW=(
|
RAINBOW=(
|
||||||
"$(printf '\033[38;5;196m')"
|
"$(printf '\033[38;5;196m')"
|
||||||
"$(printf '\033[38;5;202m')"
|
"$(printf '\033[38;5;202m')"
|
||||||
|
@ -116,6 +145,7 @@ if is_tty; then
|
||||||
"$(printf '\033[38;5;093m')"
|
"$(printf '\033[38;5;093m')"
|
||||||
"$(printf '\033[38;5;163m')"
|
"$(printf '\033[38;5;163m')"
|
||||||
)
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
RED=$(printf '\033[31m')
|
RED=$(printf '\033[31m')
|
||||||
GREEN=$(printf '\033[32m')
|
GREEN=$(printf '\033[32m')
|
||||||
|
|
Loading…
Reference in a new issue