mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-22 13:50:09 +00:00
trapd00r: look for 256-color support, not $DISPLAY
Checking if the terminal supports 256 colors is better suited for our purpose. Checking if `$DISPLAY` is set doesn't tell us if our colors will be displayed correctly.
This commit is contained in:
parent
1d26e2ab6f
commit
4774bc62d5
1 changed files with 6 additions and 3 deletions
|
@ -38,6 +38,9 @@ local c13=$(printf "\e[38;5;196m\e[1m")
|
||||||
|
|
||||||
|
|
||||||
zsh_path() {
|
zsh_path() {
|
||||||
|
local colors
|
||||||
|
colors=$(echoti colors)
|
||||||
|
|
||||||
local -A yellow
|
local -A yellow
|
||||||
yellow=(
|
yellow=(
|
||||||
1 '%F{228}' 2 '%F{222}' 3 '%F{192}' 4 '%F{186}'
|
1 '%F{228}' 2 '%F{222}' 3 '%F{192}' 4 '%F{186}'
|
||||||
|
@ -51,7 +54,7 @@ zsh_path() {
|
||||||
for c (${(s::)PWD}); do
|
for c (${(s::)PWD}); do
|
||||||
if [[ $c = "/" ]]; then
|
if [[ $c = "/" ]]; then
|
||||||
if [[ $i -eq 1 ]]; then
|
if [[ $i -eq 1 ]]; then
|
||||||
if [[ -n "$DISPLAY" ]]; then
|
if [[ $colors -ge 256 ]]; then
|
||||||
print -Pn '%F{065}%B /%b%f'
|
print -Pn '%F{065}%B /%b%f'
|
||||||
else
|
else
|
||||||
print -Pn '\e[31;1m /%f'
|
print -Pn '\e[31;1m /%f'
|
||||||
|
@ -60,14 +63,14 @@ zsh_path() {
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$DISPLAY" ]]; then
|
if [[ $colors -ge 256 ]]; then
|
||||||
print -Pn "${yellow[$i]:-%f} » %f"
|
print -Pn "${yellow[$i]:-%f} » %f"
|
||||||
else
|
else
|
||||||
print -Pn "%F{yellow} > %f"
|
print -Pn "%F{yellow} > %f"
|
||||||
fi
|
fi
|
||||||
(( i += 6 ))
|
(( i += 6 ))
|
||||||
else
|
else
|
||||||
if [[ -n "$DISPLAY" ]]; then
|
if [[ $colors -ge 256 ]]; then
|
||||||
print -Pn "%F{065}$c%f"
|
print -Pn "%F{065}$c%f"
|
||||||
else
|
else
|
||||||
print -Pn "%F{blue}$c%f"
|
print -Pn "%F{blue}$c%f"
|
||||||
|
|
Loading…
Reference in a new issue