From 48c33fdbb55bc885b91e43e6b8e6402113c81802 Mon Sep 17 00:00:00 2001 From: Miguel Palhas Date: Mon, 24 Aug 2026 12:13:38 +0100 Subject: [PATCH] perf(zsh): rebuild completion dump once a day compinit security-checked and rebuilt the dump on every shell start, the largest fixed cost before fzf-tab, atuin, zoxide, direnv and starship load. Verified both branches yield the same 1980 completions. Co-Authored-By: Claude --- home/common/programs/zsh.nix | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/home/common/programs/zsh.nix b/home/common/programs/zsh.nix index 7603720..789da7b 100644 --- a/home/common/programs/zsh.nix +++ b/home/common/programs/zsh.nix @@ -10,7 +10,18 @@ enableCompletion = true; autosuggestion.enable = true; syntaxHighlighting.enable = true; - completionInit = "autoload -U compinit && compinit -u"; + # A full compinit security-checks and rebuilds the dump on every shell + # start. Do that at most once a day and use the cached dump (-C) in + # between. Missing dump globs to nothing, so it takes the full path. + completionInit = '' + autoload -U compinit + _zcompdump_fresh() { + setopt local_options extendedglob + [[ -n ''${ZDOTDIR:-$HOME}/.zcompdump(#qNmh-24) ]] + } + if _zcompdump_fresh; then compinit -C; else compinit -u; fi + unfunction _zcompdump_fresh + ''; shellAliases = { c = "cargo";