mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-12-19 14:01:57 +00:00
colors checking optimized and added tput for check the colors
moved to colors functions, because it makes sense.
This commit is contained in:
parent
ef0f8f0ba4
commit
0c943ac6d5
2 changed files with 17 additions and 8 deletions
|
@ -6,6 +6,22 @@
|
||||||
# https://github.com/bhilburn/powerlevel9k
|
# https://github.com/bhilburn/powerlevel9k
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
|
function termColors() {
|
||||||
|
local term_colors
|
||||||
|
|
||||||
|
if which tput &>/dev/null; then
|
||||||
|
term_colors=$(tput colors)
|
||||||
|
else
|
||||||
|
term_colors=$(echotc Co)
|
||||||
|
fi
|
||||||
|
if (( ! $? && ${term_colors:-0} < 256 )); then
|
||||||
|
print -P "%F{red}WARNING!%f Your terminal appears to support fewer than 256 colors!"
|
||||||
|
print -P "If your terminal supports 256 colors, please export the appropriate environment variable"
|
||||||
|
print -P "_before_ loading this theme in your \~\/.zshrc. In most terminal emulators, putting"
|
||||||
|
print -P "%F{blue}export TERM=\"xterm-256color\"%f at the top of your \~\/.zshrc is sufficient."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# get the proper color code if it does not exist as a name.
|
# get the proper color code if it does not exist as a name.
|
||||||
function getColor() {
|
function getColor() {
|
||||||
# no need to check numerical values
|
# no need to check numerical values
|
||||||
|
|
|
@ -1572,14 +1572,7 @@ prompt_powerlevel9k_setup() {
|
||||||
setopt noprompt{bang,cr,percent,sp,subst} "prompt${^prompt_opts[@]}"
|
setopt noprompt{bang,cr,percent,sp,subst} "prompt${^prompt_opts[@]}"
|
||||||
|
|
||||||
# Display a warning if the terminal does not support 256 colors
|
# Display a warning if the terminal does not support 256 colors
|
||||||
local term_colors
|
termColors
|
||||||
term_colors=$(echotc Co 2>/dev/null)
|
|
||||||
if (( ! $? && ${term_colors:-0} < 256 )); then
|
|
||||||
print -P "%F{red}WARNING!%f Your terminal appears to support fewer than 256 colors!"
|
|
||||||
print -P "If your terminal supports 256 colors, please export the appropriate environment variable"
|
|
||||||
print -P "_before_ loading this theme in your \~\/.zshrc. In most terminal emulators, putting"
|
|
||||||
print -P "%F{blue}export TERM=\"xterm-256color\"%f at the top of your \~\/.zshrc is sufficient."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If the terminal `LANG` is set to `C`, this theme will not work at all.
|
# If the terminal `LANG` is set to `C`, this theme will not work at all.
|
||||||
local term_lang
|
local term_lang
|
||||||
|
|
Loading…
Reference in a new issue