summaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-04-30 13:56:24 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-04-30 13:56:24 +0300
commit182f0f71627a2f8b84b80ae5c320b061c987ed22 (patch)
tree2564ad482b75f32b8f76d06407191ab7d7b7133f /powerlevel9k.zsh-theme
parent96f5482a8df662205abd7bb271efd79b357d85c5 (diff)
support true color
In order to use true color with Powerlevel10k you need ZSH >= 5.7 and a terminal that supports true color. Here's how you can check whether you are covered. if autoload -U is-at-least && is-at-least 5.7; then echo "ZSH $ZSH_VERSION: supports true color" else echo "ZSH $ZSH_VERSION: does not support true color" fi if [[ $COLORTERM == (24bit|truecolor) || ${terminfo[colors]} -eq 16777216 ]]; then echo "Terminal supports true color" else echo "Terminal does not support true color" fi To use true color with Powerlevel10k, use `#ffffff` format when specifying colors. POWERLEVEL9K_TIME_FOREGROUND='red' # by name (type `getColorCode foreground` to list all) POWERLEVEL9K_TIME_BACKGROUND='001' # by decimal code (usually 001 to 256) POWERLEVEL9K_TIME_BACKGROUND='#ff0000' # by hex code (#000000 to #ffffff) In order to be able to use the same configuration from a terminal without true color support, add this to your ~/.zshrc: if [[ $COLORTERM != (24bit|truecolor) && ${terminfo[colors]} -ne 16777216 ]]; then zmodload zsh/nearcolor fi When using a true color terminal, `#ffffff` will render as true color. When on an older terminal, it'll render as the closest available color. Neat! Fixes #62.
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme7
1 files changed, 4 insertions, 3 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 5f8d1623..01a832af 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -150,10 +150,11 @@ typeset -ga _P9K_RIGHT_JOIN=(1)
_p9k_color() {
local user_var=POWERLEVEL9K_${(U)${2}#prompt_}_${3}
local color=${${(P)user_var}:-${1}}
- # Check if given value is already numerical.
- if [[ $color == <-> ]]; then
+ if [[ $color == <-> ]]; then # decimal color code: 255
_P9K_RETVAL=${(l:3::0:)color}
- else
+ elif [[ $color == '#'* ]]; then # hexademical color code: #ffffff
+ _P9K_RETVAL=$color
+ else # named color: red
# Strip prifixes if there are any.
_P9K_RETVAL=$__P9K_COLORS[${${${color#bg-}#fg-}#br}]
fi