perf(zsh): resolve brew --prefix at template time and cache completions#13
Merged
Conversation
3468423 to
c6599f4
Compare
c6599f4 to
553603b
Compare
Zsh startup was ~5.6s due to 11 runtime `brew --prefix` subshell calls (~450ms), `gt completion` (~390ms), and `op completion zsh` (4-11s). - Resolve all `brew --prefix` calls at `chezmoi apply` time using the `output` template function instead of runtime `$()` subshells - Cache `gt completion` and `zoxide init` output to $XDG_CACHE_HOME/zsh/ (generated once, sourced thereafter) - Remove duplicate asdf sourcing (was in both zshrc and tools.zsh) - Replace `which` with `command -v` (shell builtin, no fork) To invalidate completion caches: rm ~/.cache/zsh/*.zsh Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
553603b to
4899dcf
Compare
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.
Zsh startup was measured at ~5.6s. The dominant costs were
op completion zsh(4-11s, already cached in a prior commit), 11 runtimebrew --prefixsubshell calls (~450ms total),gt completion(~390ms), andzoxide init(~25ms).All
brew --prefixcalls are now resolved atchezmoi applytime using theoutputtemplate function. The rendered config contains literal/opt/homebrewpaths instead of forking Ruby on every shell init. The llvm check was also corrected from-n(always true sincebrew --prefixreturns a path regardless of install state) to-d(checks the directory actually exists).Graphite and zoxide initialization output is cached to
$XDG_CACHE_HOME/zsh/on first use and sourced from disk on subsequent inits. Runrm ~/.cache/zsh/*.zshto force regeneration after tool upgrades.A duplicate asdf sourcing was removed — it was loaded in both the zshrc darwin block and
tools.zsh, resulting in three unnecessarybrew --prefix asdfcalls. Thetools.zshcopy is kept since it also sets the required env vars.All
whichcalls replaced withcommand -v(shell builtin, avoids forking an external process).Expected startup improvement from ~5.6s to under 0.5s.
🤖 Generated with Claude Code