diff --git a/.jules/bolt.md b/.jules/bolt.md index 7aec53a2..e2166ca8 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -5,3 +5,7 @@ ## 2024-11-20 - Use Zsh Native Extended Globbing for File Staleness **Learning:** Checking file age by spawning `stat` and `date` as subprocesses adds unnecessary overhead and degrades shell startup performance. In this codebase, avoiding subprocesses is a critical optimization pattern. **Action:** Use native Zsh extended globbing (e.g., `(#qN.ms+seconds)`) coupled with `setopt local_options extended_glob` to perform file age evaluations natively within the shell, bypassing process spawning altogether. + +## 2026-07-22 - Znap Automatically Handles compinit +**Learning:** The Znap plugin manager automatically handles `compinit` and comp dumps out of the box. Manually calling `compinit` (e.g., in `.zshrc` or `zsh/znap.zsh`) degrades shell startup performance due to redundant execution and should be avoided. +**Action:** Do not manually call `compinit` when using Znap for plugin management to ensure optimal shell startup performance. diff --git a/zsh/znap.zsh b/zsh/znap.zsh index 44e54460..306f796c 100644 --- a/zsh/znap.zsh +++ b/zsh/znap.zsh @@ -3,22 +3,8 @@ zstyle ':znap:*' repos-dir ~/.zsh-snap # Extend cache TTL to reduce network requests and speed up shell startup zstyle ':znap:*:*' ttl 604800 # Cache for 7 days (in seconds) -autoload -Uz compinit -# Run full compinit when: -# - the dump doesn't exist yet (first run), OR -# - the dump is older than 24h (mh+24 = modified more than 24h ago) -# Otherwise use -C to skip the fpath security scan for faster startup. -() { - # Optimization: Use native Zsh extended globbing qualifiers efficiently - setopt local_options extended_glob - local _zcompdump="${ZDOTDIR:-$HOME}/.zcompdump" - local -a stale_dump=($_zcompdump(#qN.mh+24)) - if [[ ! -f $_zcompdump ]] || (( ${#stale_dump} > 0 )); then - compinit # no dump or stale: rebuild and re-check fpath security - else - compinit -C # dump is fresh: skip security scan for faster startup - fi -} +# Optimization: Znap automatically handles compinit and comp dumps out of the box. +# Manually calling compinit degrades shell startup performance due to redundant execution. # Download Znap, if it's not there yet. [[ -f ~/git/zsh-snap/znap.zsh ]] ||