perf: optimize shell startup with batched PATH operations and Homebrew caching

- Batch Fish PATH additions into single operation (reduces startup by ~13ms)
- Cache Homebrew shellenv output for 7 days (reduces startup by ~14ms)
- Update CLAUDE.md with TODO list update workflow guidelines
- Change default chezmoi cd shell from bash to fish
- Remove redundant bun completion sourcing in bash

Performance improvements measured through shell startup profiling.
This commit is contained in:
Ryan Walters
2025-10-27 15:51:07 -05:00
parent d031952070
commit f8f0e0e615
4 changed files with 73 additions and 35 deletions

View File

@@ -28,7 +28,23 @@ if [ -d "$HOME/.deno" ]; then
. "$HOME/.deno/env" # Deno
fi
. "$HOME/.cargo/env" # Rustup + Cargo + Cargo-installed tools
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" # Brew
# Homebrew (cached for performance - reduces startup time by ~14ms)
if [ -f /home/linuxbrew/.linuxbrew/bin/brew ]; then
BREW_CACHE="$HOME/.cache/brew_env.sh"
BREW_BIN="/home/linuxbrew/.linuxbrew/bin/brew"
# Regenerate cache if: doesn't exist, >7 days old, or brew binary is newer
if [ ! -f "$BREW_CACHE" ] || \
[ $(( $(date +%s) - $(stat -c %Y "$BREW_CACHE" 2>/dev/null || echo 0) )) -gt 604800 ] || \
[ "$BREW_BIN" -nt "$BREW_CACHE" ]; then
mkdir -p "$(dirname "$BREW_CACHE")"
"$BREW_BIN" shellenv > "$BREW_CACHE" 2>/dev/null
fi
[ -f "$BREW_CACHE" ] && . "$BREW_CACHE"
fi
command -v rbenv &> /dev/null && eval "$(rbenv init -)" # rbenv for Ruby
command -v chatgpt &> /dev/null && . <(chatgpt --set-completions {{ .shell -}}) # chatgpt completions
{{ if eq .shell "bash" -}}
@@ -50,7 +66,6 @@ fi
# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
[ -s "$HOME/.bun/_bun" ] && source "$HOME/.bun/_bun"
# java version manager
if [ -d $HOME/.jenv/bin ]; then