feat: split zshrc into a stub and role-aware fragments
Load order is the substance of this change, and two attempts got it wrong in
the same way. oh-my-zsh consumes both the plugins array and the theme while it
is being sourced, so anything set afterwards is silently ignored. The plan had
plugins in the stub but the theme in the role file, which produced a shell
reporting ZSH_THEME=powerlevel10k while running without powerlevel10k at all -
132 of its functions missing and nobody any the wiser. Plugins and prompt are
now both resolved before oh-my-zsh, the latter in 05-prompt.zsh.
Portability is handled by asking whether a command exists rather than by
duplicating files per role. "alias ls='lsd'" turns ls into a broken command on
a machine without lsd, and the Mac is such a machine; the yay aliases and
helpers are gated the same way. That keeps one shared base instead of three
diverging copies.
The plan also guessed the plugin list as (git fzf). It is actually seven
entries, so five would have vanished - among them signal-keyring, which turned
out to be a local custom plugin present on this machine only. Naming it
elsewhere means an oh-my-zsh warning at every login, and its content is a
verbatim copy of the gnome-keyring block already in .zshrc, so it ran twice.
The inline block stays, in the desktop role; the plugin is dropped.
Dead code removed rather than carried over:
- PYTHONPATH pointed at /usr/lib/python3.9/site-packages. Python here is
3.14 and that directory does not exist.
- XDG_SESSION_TYPE was forced to x11 and then tested for "wayland" six lines
below, so that branch could never be taken. The variable belongs to the
session; overriding it lies to everything that reads it.
- drm() was defined twice, the first losing to the second on every start.
- PATH carried ~/bin, ~/.scripts and /usr/X11R6/bin, none of which exist.
Entries are added only if the directory is there.
Verified against the live configuration in an isolated ZDOTDIR: 277 aliases and
263 functions on both sides, none missing, and powerlevel10k loading for all
three roles with the intended colour.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
49357eced4
commit
ce560c315d
@@ -0,0 +1,32 @@
|
||||
# Prompt. Sourced by the stub BEFORE oh-my-zsh, and that placement is the whole
|
||||
# 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.
|
||||
|
||||
# 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
|
||||
Reference in New Issue
Block a user