dotfiles: Cut Zsh startup cost and stabilize session tooling - #31
Merged
Conversation
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.
dotfiles: Cut Zsh startup cost and stabilize session tooling
This checkpoint removes Oh My Zsh from the interactive startup path, keeps the
commands needed at the first prompt available, and moves expensive Goenv setup
behind Zinit Turbo with a first-use fallback. It also carries the branch's
clipboard recovery, Neovim polish, and Herdr tab-position work.
Rationale
The old shell loaded Oh My Zsh as a framework to obtain a small set of plugins.
That also loaded its general libraries and initialized Powerlevel10k twice.
Profiling found a larger cost in
goenv init -, roughly 566 ms, even though Goshims only need the Goenv paths already in
PATH.The shell should become usable before optional integration and completion work
finishes. That cannot come at the cost of a broken first command. Git aliases,
the
zcommand, vi mode, and Go shims therefore remain ready at the firstprompt. The Goenv function has a synchronous first-use path for the narrow
window before its Turbo task runs.
Key Changes
Git aliases, and
zload synchronously.jsontools,sudo, and syntaxhighlighting use Turbo.
time, then recorded a 20-run result after five warmups.
goenv init -through a linked local Zinit snippet while keepingGoenv shims in
PATHand providing a first-usegoenvtrigger.socket path safe in both Bash and Zsh startup files.
just health, moved Zsh-specific code into.zshfiles, and documented the resulting setup.support, Neovim Markdown and visual updates, and the guarded
.nvmrcCLI.1 - Shell startup and first-use behavior
zinit-install.shpins the Zinit checkout and prefetches all remote pluginsduring
just sync. It also creates the linked local Goenv snippet withoutsourcing it, so a fresh interactive shell does not print setup output or fetch
anything.
The Goenv snippet runs
command goenv init -. Thecommandprefix bypassesthe temporary trigger and prevents recursive loading.
GOENV_ROOT, itsbindirectory, and its shim directory stay in
PATH, sogo versionkeeps workingeven before the full Goenv function and completions load.
The NVM wrapper remains deliberately separate. It loads only when the user
types
nvm; this PR does not makenodechoose a project version implicitly.2 - Measured result and benchmark boundary
just bench-zsh --mode initmeasures the synchronous path before Zinit'sTurbo callbacks run.
--mode promptstarts an interactive shell in apseudo-terminal and stops when ZLE accepts input. Neither number claims that
every deferred plugin has finished loading.
These numbers are local measurements, not a promise for every machine. They
are still a useful checkpoint because the before and after runs use the same
20-run, five-warmup method. The documentation includes the commands needed to
repeat them.
3 - Shared session state and configuration checks
ssh_setupremains an explicit command for adding the configured identityfiles. New terminals reuse keys already present in the shared agent, avoiding
startup work while keeping Git SSH usable once the session has been prepared.
zshenvnow sets XDG directories, editor defaults, the stable agent socket,and
GPG_TTYonly when a terminal exists. The socket expression avoids theZsh-only nested parameter expansion that made Bash consumers fail.
just healthchecks core shared files withbash -nand Zsh-only files withzsh -n.4 - Other changes included in this branch
The branch also recovers the WSL clipboard backend after its PowerShell child
dies, adds configured tab positions to Herdr, and updates Neovim's Markdown
rendering, list continuation, cursor, and indent-guide appearance. The
.nvmrcutility lists pins below a selected root and only rewrites allowlistedrepositories unless
--allis explicit. These changes are independent of thestartup work but are part of this checkpoint's comparison with
main.