From 6b7e057bd4fc2cbdffe5fc8b3095810db1ccf9e3 Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Fri, 22 May 2026 10:41:24 +0100 Subject: feat(zsh): recover Arch site-functions + HELPDIR after removing system zsh Switching to nix's zsh on the Arch host left two functional gaps the Arch zsh package used to fill: 1. /usr/share/zsh/site-functions in fpath: pacman, paru, systemctl, journalctl, flatpak, docker, kubectl, makepkg etc. drop their completions there. nix zsh's compiled-in fpath doesn't include /usr/share so we lose all of them silently. Added that path (and vendor-completions for the VM's apt-installed completions) to the existing fpath loop, guarded by [[ -d ]]. 2. HELPDIR for the run-help / help-alias machinery: needed so 'help cd' etc. find the per-builtin help docs. Pick the first existing version dir, preferring nix-profile so it matches the running zsh version. --- dot_config/zsh/dot_zshrc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/dot_config/zsh/dot_zshrc b/dot_config/zsh/dot_zshrc index 961a5b4..b1021eb 100644 --- a/dot_config/zsh/dot_zshrc +++ b/dot_config/zsh/dot_zshrc @@ -42,13 +42,28 @@ PROMPT='%B%{$fg[green]%}%n%{$reset_color%}@%{$fg[cyan]%}%m%{$reset_color%}:%b%{$ # ── Completion ──────────────────────────────────────────────────────────────── fpath=($XDG_DATA_HOME/zsh/completion $fpath) -# Pick up completions shipped by nix-installed packages on the remote-dev VM -# (Ubuntu's system zsh doesn't add the nix-profile share dirs to fpath). +# Pull in completions from both nix-installed packages AND the system +# package manager (pacman on Arch host, apt on Ubuntu VM). nix zsh's +# default fpath only includes its own nix-store dirs, so without these +# entries we miss completions for pacman, paru, systemctl, flatpak, +# docker, kubectl, etc. on the host, and apt/snap on the VM. for _d in "$HOME/.nix-profile/share/zsh/site-functions" \ - "$HOME/.nix-profile/share/zsh/vendor-completions"; do + "$HOME/.nix-profile/share/zsh/vendor-completions" \ + /usr/share/zsh/site-functions \ + /usr/share/zsh/vendor-completions; do [[ -d $_d ]] && fpath=($_d $fpath) done unset _d +# HELPDIR: location of per-builtin help docs used by run-help/`help`. +# Pick whichever exists, preferring nix-profile (newer zsh version +# matches our running shell). The glob expands to the version-specific +# dir, e.g. ~/.nix-profile/share/zsh/5.9/help. +# shellcheck disable=SC1036,SC1058,SC1072,SC1073 # zsh glob qualifier (N) +for _d in "$HOME"/.nix-profile/share/zsh/*/help(N) \ + /usr/share/zsh/*/help(N); do + [[ -d $_d ]] && { export HELPDIR=$_d; break; } +done +unset _d autoload -Uz compinit && compinit -d "$XDG_CACHE_HOME/zsh/zcompdump" zstyle ':completion:*' menu select # arrow-key driven menu for ambiguous completions -- cgit v1.3.1