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.kopp
2026-08-07 16:21:36 +02:00
co-authored by Claude Opus 5
parent b87975402d
commit fad8b8f78c
5 changed files with 43 additions and 27 deletions
+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
+12
View File
@@ -5,6 +5,18 @@
# machine where lsd is not installed - the Mac, for one - and breaking ls is
# the sort of thing that makes a shared dotfile repository feel like a mistake.
# The dotfiles repository itself. A bare repo in ~/.cfg with $HOME as its work
# tree, so "config" behaves like git for the configuration and the real git
# stays out of the way in ordinary projects.
#
# config status what has drifted
# config add .zshrc track a change
# config commit -m ... and push as usual
#
# status.showUntrackedFiles=no is set in the repo, otherwise every file in
# $HOME would show up as untracked.
[[ -d "$HOME/.cfg" ]] && alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
alias vi="nvim"
alias ducks="du -cksh * | sort -rn | head"
+6
View File
@@ -38,3 +38,9 @@ for _d in "$HOME/.cargo/bin" "$HOME/.lmstudio/bin"; do
done
unset _d
export PATH
# Role colour, set here rather than in 05-prompt.zsh because ~/.p10k.zsh
# assigns POWERLEVEL9K_CONTEXT_BACKGROUND itself and is sourced in 30-path.zsh.
# Anything set before that is silently replaced. Not decoration: shron carries
# mail, web and cloud, and a glance should say which machine this is.
typeset -g POWERLEVEL9K_CONTEXT_BACKGROUND=blue
+6
View File
@@ -14,3 +14,9 @@ for _b in /opt/homebrew /usr/local; do
fi
done
unset _b
# Role colour, set here rather than in 05-prompt.zsh because ~/.p10k.zsh
# assigns POWERLEVEL9K_CONTEXT_BACKGROUND itself and is sourced in 30-path.zsh.
# Anything set before that is silently replaced. Not decoration: shron carries
# mail, web and cloud, and a glance should say which machine this is.
typeset -g POWERLEVEL9K_CONTEXT_BACKGROUND=green
+9
View File
@@ -4,3 +4,12 @@
# out of the way; anything that assumes a graphical session belongs in
# 50-desktop.zsh.
# Role colour, set here rather than in 05-prompt.zsh because ~/.p10k.zsh
# assigns POWERLEVEL9K_CONTEXT_BACKGROUND itself and is sourced in 30-path.zsh.
# Anything set before that is silently replaced. Not decoration: shron carries
# mail, web and cloud, and a glance should say which machine this is.
typeset -g POWERLEVEL9K_CONTEXT_BACKGROUND=red
# Show the host even in a local shell. Noise on a desktop; here it is the one
# thing worth always having in view.
typeset -g POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true