fix: set the role colour after .p10k.zsh, and add the config alias

The colour was in 05-prompt.zsh, before oh-my-zsh. That is right for ZSH_THEME
and wrong for everything else: ~/.p10k.zsh assigns
POWERLEVEL9K_CONTEXT_BACKGROUND itself and is sourced from 30-path.zsh, so the
role colour was overwritten before the first prompt was drawn. The isolated
test missed it because the throwaway HOME had no .p10k.zsh; on the real machine
the desktop came up with 0 instead of blue.

Theme before oh-my-zsh, colour after .p10k.zsh - two different constraints that
happen to pull in opposite directions.

The config alias was missing entirely. Without it the bare repository has no
front end, which makes the whole arrangement unusable. Guarded on ~/.cfg
existing so the alias does not appear on a machine that has not been set up.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
thomas.koppandClaude Opus 5 committed 2026-08-07 16:21:36 +02:00
1 parent b87975402d
commit fad8b8f78c
5 files changed
+43 -27

No files matched your search

+10 -27
View File
@@ -1,32 +1,15 @@
# Prompt. Sourced by the stub BEFORE oh-my-zsh, and that placement is the whole
# point of the file.
# Theme selection. Sourced by the stub BEFORE oh-my-zsh, and that placement is
# the point of the file.
#
# oh-my-zsh loads the theme while it is being sourced, and powerlevel10k reads
# its POWERLEVEL9K_* settings when it loads. Anything set afterwards is simply
# ignored - the first attempt put ZSH_THEME in the role file, which is sourced
# after oh-my-zsh, and the result was a shell with no powerlevel10k at all
# while still reporting the right value in ZSH_THEME.
# oh-my-zsh loads the theme while it is being sourced, so ZSH_THEME set
# afterwards is ignored - the first attempt put it in the role file and produced
# a shell reporting the right value while running without powerlevel10k at all.
#
# The role COLOUR is deliberately not here. ~/.p10k.zsh sets
# POWERLEVEL9K_CONTEXT_BACKGROUND itself and is sourced later, so a colour set
# here is overwritten before the first prompt is ever drawn. It lives in the
# role files, which come after.
# Only claim the theme if it is actually installed, otherwise oh-my-zsh falls
# back to robbyrussell with a complaint.
if [[ -d "${ZSH_CUSTOM:-$ZSH/custom}/themes/powerlevel10k" ]]; then
ZSH_THEME="powerlevel10k/powerlevel10k"
fi
# Colour by role. Not decoration: shron carries mail, web and cloud, and a
# glance at the prompt should be enough to know which machine the next command
# is about to hit. Same segments everywhere so nothing else has to be relearned.
case "$ROLE" in
server)
typeset -g POWERLEVEL9K_CONTEXT_BACKGROUND=red
# Show the host even locally. Noise on a desktop, the one thing worth
# always seeing here.
typeset -g POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
;;
mobile)
typeset -g POWERLEVEL9K_CONTEXT_BACKGROUND=green
;;
*)
typeset -g POWERLEVEL9K_CONTEXT_BACKGROUND=blue
;;
esac