Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

## $(date +%Y-%m-%d) - Redundant compinit inside znap configuration

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The shell command substitution $(date +%Y-%m-%d) was written literally into the markdown file instead of being evaluated to the actual date. Please replace it with the actual date of this change.

Suggested change
## $(date +%Y-%m-%d) - Redundant compinit inside znap configuration
## YYYY-MM-DD - Redundant compinit inside znap configuration

**Learning:** The `znap` (zsh-snap) plugin manager natively handles completion initialization (`compinit`) and caching out of the box. Manually executing `compinit` inside configuration files loaded by `znap` is redundant and significantly degrades startup performance.
**Action:** Do not manually call `compinit` when `znap` is in use. Let `znap` manage completion caching to ensure optimal shell initialization times.
19 changes: 3 additions & 16 deletions zsh/znap.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,9 @@ 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: Do NOT call compinit manually here.
# Znap handles compinit and comp dumps automatically out of the box.
# Calling it manually degraded shell startup performance redundantly.

# Download Znap, if it's not there yet.
[[ -f ~/git/zsh-snap/znap.zsh ]] ||
Expand Down
Loading