Repository navigation
perf: cut fish and zsh shell startup time - #133
Open
chianyungcode wants to merge 3 commits into
Open
chianyungcode wants to merge 3 commits into
chianyungcode wants to merge 3 commits into
Conversation
Startup spawned atuin, starship, direnv, jw and zoxide on every launch to generate their init scripts. Cache the output under $XDG_CACHE_HOME/fish/init, keyed on each binary's resolved path and mtime so it rebuilds after upgrades. - add __cached_source helper (01_cached-init.fish) - shadow the vendor direnv.fish hook with a cached one - generate ATUIN_SESSION in fish instead of spawning `atuin uuid` - drop jw's eager completion sourcing; completions/jw.fish covers it - only source the herdr hook inside a herdr pane fish -i -c exit: 79 ms -> 29 ms (hyperfine). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Startup ran a second, uncached compinit from nix-darwin's /etc/zshrc, spawned starship and jw to generate their init scripts, and eagerly loaded oh-my-zsh plugins that fork on load. - skip nix-darwin's /etc/zshrc via NOSYSZSHRC (duplicate compinit with compaudit, promptinit, bashcompinit) - add __cached_source helper (000-cached-init.zsh), keyed on the binary's resolved path and mtime, for starship, jw, atuin and zoxide - bake starship's PROMPT2 into the cache; drop it when starship.toml changes - generate ATUIN_SESSION in zsh instead of spawning `atuin uuid` - drop jw's eager completion eval; completions/_jw covers it - defer the oh-my-zsh brew/git/npm plugins (`git version`, `rm` forks) - run compinit after conf.d so plugin fpath entries land in the dump, queueing earlier compdef calls; make the daily full check actually work and zcompile the dump in the background - only source the herdr hook inside a herdr pane zsh -i -c exit: 98 ms -> 34.5 ms (hyperfine). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The oh-my-zsh brew plugin is now deferred, so it loads after bun.sh and its ba/bi/bu aliases (brew autoremove/install/update) replaced the bun ones. Rename the bun aliases to bna/bni/bnu. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes CHE-21
Why
Every new shell ran atuin, starship, direnv, jw and zoxide just to print their setup scripts. zsh also set up completions twice (once in nix-darwin's
/etc/zshrc, once in.zshrc), and it loaded oh-my-zsh plugins that start extra processes before the first prompt.Result (hyperfine,
<shell> -i -c exit):Summary
fish (
89f7c41)__cached_source, which saves each tool's setup script under~/.cache/fish/init/and only re-runs the tool when its binary changes.conf.d/direnv.fishthat replaces Homebrew's copy.atuin uuid.completions/jw.fishalready covers them.zsh (
6b25d5a)000-cached-init.zsh) for starship, jw, atuin and zoxide. Starship'sPROMPT2is cached too, and cleared whenstarship.tomlchanges./etc/zshrc(NOSYSZSHRC=1).compinitafterconf.d, holding earliercompdefcalls and replaying them. Fix the daily full check, and compile the dump in the background.brew,gitandnpmplugins just after the first prompt.zsh bun aliases (
97fb088)brewplugin now loads afterbun.sh, so itsba,biandbureplaced the bun aliases (baranbrew autoremove). Rename the bun ones tobna,bniandbnu. Fish keepsba,biandbu.Tradeoffs
zsh -i -cshells never get the git, brew or npm plugin aliases.rm ~/.cache/zsh/zcompdump-*to refresh)._ZO_*variables, runrm -rf ~/.cache/{zsh,fish}/init./etc/zshrcdropsHIST_FCNTL_LOCKand any zsh settings added in nix-darwin later.Test plan
bna/bni/bnurun bun,ba/bi/burun brew🤖 Generated with Claude Code