zsh: more logic fixes for context color

This commit is contained in:
2023-07-12 07:10:37 -04:00
parent f97d58c956
commit 5cb0a778af

View File

@@ -72,7 +72,7 @@ function dotfiles-update() {
function context-color() {
hexcount=$(($(infocmp -1 | sed -n -e 's/^\t*colors#\([0-9]x\?[0-9]*\),.*/\1/p')-1))
hash=$(printf "%d\n" "0x$(hostname | md5sum | head -c 6 | tr '[:lower:]' '[:upper:]')")
excludes="0,7,15,253"
excludes="0,7,15"
id=$(( $hash % $hexcount ))
for excid in $(echo "$excludes" | tr "," '\n'); do
if [ "$id" -eq "$excid" ]; then
@@ -94,7 +94,7 @@ typeset -g POWERLEVEL9K_CONTEXT_PREFIX=
typeset -g POWERLEVEL9K_CONTEXT_DEFAULT_BACKGROUND=$(context-color)
typeset -g POWERLEVEL9K_CONTEXT_REMOTE_BACKGROUND=${POWERLEVEL9K_CONTEXT_DEFAULT_BACKGROUND}
typeset -g POWERLEVEL9K_CONTEXT_USE_BLACK_FG=(253)
if [[ -n "${POWERLEVEL9K_CONTEXT_USE_BLACK_FG}[(r)${POWERLEVEL9K_CONTEXT_DEFAULT_BACKGROUND}]}" ]]; then
if [[ -n "${POWERLEVEL9K_CONTEXT_USE_BLACK_FG[(r)${POWERLEVEL9K_CONTEXT_DEFAULT_BACKGROUND}]}" ]]; then
typeset -g POWERLEVEL9K_CONTEXT_DEFAULT_FOREGROUND=0
typeset -g POWERLEVEL9K_CONTEXT_REMOTE_FOREGROUND=0
else;