From 8db9aa926d2109bf81bfbb13ebda8234679b7b15 Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Sun, 15 Feb 2026 18:31:04 +0000 Subject: [PATCH] Speed up shell startup: remove duplicate compinit, lazy-load pyenv/nvm - Remove manual compinit in .zshrc (oh-my-zsh already handles it), eliminating a redundant ~350ms call - Lazy-load pyenv init (~710ms) until first use, matching the existing kubectl lazy-load pattern - Lazy-load nvm init for when it gets installed in the future --- dot_oh-my-zsh/custom/tools/nvm.zsh | 12 ++++++++++-- dot_oh-my-zsh/custom/tools/pyenv.zsh | 10 +++++++--- dot_zshrc | 10 ---------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/dot_oh-my-zsh/custom/tools/nvm.zsh b/dot_oh-my-zsh/custom/tools/nvm.zsh index ad5a118..267749a 100644 --- a/dot_oh-my-zsh/custom/tools/nvm.zsh +++ b/dot_oh-my-zsh/custom/tools/nvm.zsh @@ -1,6 +1,14 @@ # NVM (Node Version Manager) configuration # Auto-loaded by oh-my-zsh from $ZSH_CUSTOM/tools/ +# Lazy-loaded: defers nvm init until first use export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" -[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" + +if [[ -s "$NVM_DIR/nvm.sh" ]]; then + function nvm() { + unfunction nvm + \. "$NVM_DIR/nvm.sh" + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" + nvm "$@" + } +fi diff --git a/dot_oh-my-zsh/custom/tools/pyenv.zsh b/dot_oh-my-zsh/custom/tools/pyenv.zsh index 0c794b7..60a4f98 100644 --- a/dot_oh-my-zsh/custom/tools/pyenv.zsh +++ b/dot_oh-my-zsh/custom/tools/pyenv.zsh @@ -1,11 +1,15 @@ -# Pyenv configuration +# Pyenv configuration (lazy-loaded) # Auto-loaded by oh-my-zsh from $ZSH_CUSTOM/tools/ export PYENV_ROOT="$HOME/.pyenv" [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH" -if command -v pyenv >/dev/null 2>&1; then - eval "$(pyenv init - zsh)" +if (( $+commands[pyenv] )); then + function pyenv() { + unfunction pyenv + eval "$(command pyenv init - zsh)" + pyenv "$@" + } fi # Virtualenvwrapper diff --git a/dot_zshrc b/dot_zshrc index 88aa1f9..ce48aa7 100644 --- a/dot_zshrc +++ b/dot_zshrc @@ -1,13 +1,3 @@ -# ============================================================================ -# Fast compinit - cache completions, regenerate once daily -# ============================================================================ -autoload -Uz compinit -if [[ -n ${ZDOTDIR:-$HOME}/.zcompdump(#qN.mh+24) ]]; then - compinit -else - compinit -C -fi - # ~/.zshrc - Zsh configuration for interactive shells # Customizations are in ~/.oh-my-zsh/custom/*.zsh (auto-loaded)