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>
64 lines
2.7 KiB
Bash
64 lines
2.7 KiB
Bash
# Stub only. Everything of substance lives in ~/.config/zsh/rc.d/.
|
|
#
|
|
# Load order, and why it is this one:
|
|
#
|
|
# 1. p10k instant prompt must be the first thing that runs
|
|
# 2. role needed before plugins, see below
|
|
# 3. plugins must be set before oh-my-zsh reads them
|
|
# 4. oh-my-zsh
|
|
# 5. rc.d/[1-4]*.zsh shared by every machine
|
|
# 6. rc.d/50-<role>.zsh exactly one of desktop/server/mobile
|
|
# 7. rc.d/90-local.zsh machine-local, never in the repository
|
|
#
|
|
# Step 3 is the reason the role is resolved so early: oh-my-zsh consumes the
|
|
# plugins array while sourcing, so nothing loaded afterwards can influence it.
|
|
|
|
# Must stay at the top: this block may print, and anything above it that also
|
|
# prints breaks the instant prompt. Absent on machines without powerlevel10k,
|
|
# where the test simply fails and nothing happens.
|
|
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
|
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
|
fi
|
|
|
|
export ZSH="$HOME/.oh-my-zsh"
|
|
|
|
# Defaults to desktop so a machine without the file still gets a working shell.
|
|
# Servers must have it in place before the first login, or shron comes up on
|
|
# the desktop profile - blue prompt on a production mail server.
|
|
ROLE=$(cat "$HOME/.config/dotconfs/role" 2>/dev/null || echo desktop)
|
|
export ROLE
|
|
|
|
# One list for every machine, filtered by what is actually installed. A plugin
|
|
# named but not present makes oh-my-zsh complain on every single shell start,
|
|
# and the alternative - a separate list per role - means editing three files to
|
|
# add one plugin.
|
|
_want_plugins=(git archlinux colored-man-pages colorize zsh-interactive-cd fzf)
|
|
plugins=()
|
|
for _p in $_want_plugins; do
|
|
if [[ -d "$ZSH/plugins/$_p" || -d "${ZSH_CUSTOM:-$ZSH/custom}/plugins/$_p" ]]; then
|
|
plugins+=("$_p")
|
|
fi
|
|
done
|
|
unset _p _want_plugins
|
|
|
|
zstyle ':omz:update' mode auto
|
|
|
|
# Also before oh-my-zsh: it loads the theme while sourcing, and powerlevel10k
|
|
# reads its settings when it loads. Putting either in the role file - which is
|
|
# sourced afterwards - leaves the value set and the theme unloaded.
|
|
[[ -r "$HOME/.config/zsh/rc.d/05-prompt.zsh" ]] && source "$HOME/.config/zsh/rc.d/05-prompt.zsh"
|
|
|
|
source "$ZSH/oh-my-zsh.sh"
|
|
|
|
# (N) makes an empty directory a no-op instead of an error.
|
|
for _f in "$HOME"/.config/zsh/rc.d/[1-4]*.zsh(N); do
|
|
source "$_f"
|
|
done
|
|
unset _f
|
|
|
|
[[ -r "$HOME/.config/zsh/rc.d/50-$ROLE.zsh" ]] && source "$HOME/.config/zsh/rc.d/50-$ROLE.zsh"
|
|
|
|
# Last on purpose: this one can override anything above without the repository
|
|
# needing to know about it.
|
|
[[ -r "$HOME/.config/zsh/rc.d/90-local.zsh" ]] && source "$HOME/.config/zsh/rc.d/90-local.zsh"
|