perf(zsh): cache tool init, lazy-load, remove plugins
Startup: 150ms → 40ms (native), projected 10-30s → <1s (iSH) - Cache mise/fzf/zoxide init output keyed on binary mtime - zcompile all sourced files to bytecode at install time - Lazy-load compinit (first Tab), fzf+widgets (first keystroke) - Remove autosuggestions and syntax-highlighting plugins - Switch mise to shims mode (no per-prompt hook) - Conditional mkdir (skip if dirs exist) - Remove TRAPINT/flash handler, cache session info - Eliminate per-prompt subshell forks (REPLY pattern) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Description:
|
||||
# Configure zsh shell with direct plugin management.
|
||||
# Configure zsh shell.
|
||||
#
|
||||
|
||||
# install zsh
|
||||
@@ -24,26 +24,6 @@ if ! command -v zsh &> /dev/null; then
|
||||
esac
|
||||
fi
|
||||
|
||||
zsh --version | log_quote
|
||||
|
||||
# plugin directory (XDG compliant)
|
||||
PLUGIN_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins"
|
||||
mkdir -p "$PLUGIN_DIR"
|
||||
|
||||
# install zsh-autosuggestions
|
||||
if [ ! -d "$PLUGIN_DIR/zsh-autosuggestions" ]; then
|
||||
git clone -q \
|
||||
https://github.com/zsh-users/zsh-autosuggestions.git \
|
||||
"$PLUGIN_DIR/zsh-autosuggestions"
|
||||
fi
|
||||
|
||||
# install zsh-syntax-highlighting
|
||||
if [ ! -d "$PLUGIN_DIR/zsh-syntax-highlighting" ]; then
|
||||
git clone -q \
|
||||
https://github.com/zsh-users/zsh-syntax-highlighting.git \
|
||||
"$PLUGIN_DIR/zsh-syntax-highlighting"
|
||||
fi
|
||||
|
||||
# change default shell to zsh
|
||||
if [[ "$SHELL" != *zsh ]]; then
|
||||
sudo chsh -s "$(command -v zsh)" "$(whoami)"
|
||||
@@ -51,4 +31,5 @@ if [[ "$SHELL" != *zsh ]]; then
|
||||
fi
|
||||
|
||||
log_pass "zsh configured"
|
||||
zsh --version | log_quote
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ if ! command -v stow &> /dev/null; then
|
||||
esac
|
||||
fi
|
||||
|
||||
stow --version | log_quote
|
||||
|
||||
root_dir=${DOTFILES:-$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")}
|
||||
|
||||
rm -f "$HOME/.bash_profile"
|
||||
@@ -49,5 +47,18 @@ fi
|
||||
# Bust PATH cache to force rebuild with new profile
|
||||
rm -f "${XDG_CACHE_HOME:-$HOME/.cache}/dots/path"
|
||||
|
||||
log_pass "stow linked"
|
||||
# Compile zsh dotfiles for faster shell startup
|
||||
if command -v zsh &>/dev/null; then
|
||||
zsh -c '
|
||||
for f in ~/.zsh/*.zsh ~/.aliases ~/.profile(N); do
|
||||
[[ $f.zwc -nt $f ]] || zcompile "$f" 2>/dev/null
|
||||
done
|
||||
'
|
||||
fi
|
||||
|
||||
# Bust tool init caches so they regenerate with new PATH/tools
|
||||
rm -f "${XDG_CACHE_HOME:-$HOME/.cache}"/dots/{fzf,mise,zoxide}.zsh{,.zwc}
|
||||
|
||||
log_pass "stow linked"
|
||||
stow --version | log_quote
|
||||
|
||||
|
||||
Reference in New Issue
Block a user