mirror of
https://github.com/Xevion/dotfiles.git
synced 2025-12-06 17:14:52 -06:00
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:
11
CLAUDE.md
11
CLAUDE.md
@@ -86,6 +86,17 @@ This is a **chezmoi source directory** for managing dotfiles across multiple mac
|
|||||||
- Doppler secrets: `{{ dopplerProjectJson.SECRET_NAME }}`
|
- Doppler secrets: `{{ dopplerProjectJson.SECRET_NAME }}`
|
||||||
- Conditional logic: `{{ if }}...{{ else }}...{{ end }}`
|
- Conditional logic: `{{ if }}...{{ else }}...{{ end }}`
|
||||||
|
|
||||||
|
5. **Suggest TODO list updates** (but DO NOT modify automatically)
|
||||||
|
- When a task is completed, check if `TODO.md` exists in the repository
|
||||||
|
- If the completed task relates to items in TODO.md, **suggest** updating the file
|
||||||
|
- Examples of suggestions:
|
||||||
|
- "I've completed [task]. Would you like me to update TODO.md to mark this item as complete?"
|
||||||
|
- "This work relates to items in TODO.md. Should I update the relevant checkboxes?"
|
||||||
|
- **NEVER** modify TODO.md without explicit user approval
|
||||||
|
- User must explicitly approve (even if not specifically) before making changes
|
||||||
|
- Acceptable approvals: "yes", "go ahead", "update it", "sure", etc.
|
||||||
|
- If unclear, ask: "Should I update TODO.md to reflect this completion?"
|
||||||
|
|
||||||
## Common Tasks
|
## Common Tasks
|
||||||
|
|
||||||
**Add new dotfile:**
|
**Add new dotfile:**
|
||||||
|
|||||||
@@ -73,5 +73,5 @@ args = [
|
|||||||
command = "nu"
|
command = "nu"
|
||||||
{{ else }}
|
{{ else }}
|
||||||
[cd]
|
[cd]
|
||||||
command = "bash"
|
command = "fish"
|
||||||
{{ end }}
|
{{ end }}
|
||||||
@@ -10,72 +10,84 @@ set -gx TERM xterm-256color # fixes terminal colors when ssh'ing into laptop
|
|||||||
# Authentication
|
# Authentication
|
||||||
set -gx OPENAI_API_KEY "{{ dopplerProjectJson.OPENAI_CHATGPT_CLI }}"
|
set -gx OPENAI_API_KEY "{{ dopplerProjectJson.OPENAI_CHATGPT_CLI }}"
|
||||||
|
|
||||||
# hishtory (lazy-loaded via __init_hishtory function)
|
# PATH setup (batched for performance - reduces startup time by ~13ms)
|
||||||
test -d $HOME/.hishtory && fish_add_path $HOME/.hishtory
|
set -l paths_to_add
|
||||||
|
|
||||||
# PATH setup
|
# Collect paths with conditional checks
|
||||||
test -d $HOME/bin && fish_add_path $HOME/bin
|
test -d $HOME/.hishtory && set -a paths_to_add $HOME/.hishtory
|
||||||
fish_add_path /usr/local/bin
|
test -d $HOME/bin && set -a paths_to_add $HOME/bin
|
||||||
fish_add_path $HOME/.local/bin
|
set -a paths_to_add /usr/local/bin $HOME/.local/bin
|
||||||
test -d /usr/local/go/bin && fish_add_path /usr/local/go/bin # Go
|
test -d /usr/local/go/bin && set -a paths_to_add /usr/local/go/bin # Go
|
||||||
test -d $HOME/go/bin && fish_add_path $HOME/go/bin # Go-installed tools
|
test -d $HOME/go/bin && set -a paths_to_add $HOME/go/bin # Go-installed tools
|
||||||
test -d $HOME/.local/share/bob/nvim-bin && fish_add_path $HOME/.local/share/bob/nvim-bin # Bob, Neovim package manager
|
test -d $HOME/.local/share/bob/nvim-bin && set -a paths_to_add $HOME/.local/share/bob/nvim-bin # Bob, Neovim package manager
|
||||||
|
|
||||||
# Deno
|
# Deno (conditionally source env file or add to path list)
|
||||||
if test -d $HOME/.deno
|
if test -d $HOME/.deno
|
||||||
source $HOME/.deno/env.fish 2>/dev/null || set -gx DENO_INSTALL $HOME/.deno && fish_add_path $DENO_INSTALL/bin
|
if not source $HOME/.deno/env.fish 2>/dev/null
|
||||||
|
set -gx DENO_INSTALL $HOME/.deno
|
||||||
|
set -a paths_to_add $DENO_INSTALL/bin
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Rust (Cargo)
|
# Rust/Cargo (source env file or add to path list)
|
||||||
if test -f $HOME/.cargo/env.fish
|
if test -f $HOME/.cargo/env.fish
|
||||||
source $HOME/.cargo/env.fish
|
source $HOME/.cargo/env.fish
|
||||||
else if test -f $HOME/.cargo/env
|
else if test -f $HOME/.cargo/env
|
||||||
# Fallback: parse bash env file
|
# Fallback: parse bash env file
|
||||||
set -gx CARGO_HOME $HOME/.cargo
|
set -gx CARGO_HOME $HOME/.cargo
|
||||||
fish_add_path $CARGO_HOME/bin
|
set -a paths_to_add $CARGO_HOME/bin
|
||||||
end
|
end
|
||||||
|
|
||||||
# Homebrew
|
# Homebrew (cached for performance - reduces startup time by ~14ms)
|
||||||
if test -f /home/linuxbrew/.linuxbrew/bin/brew
|
if test -f /home/linuxbrew/.linuxbrew/bin/brew
|
||||||
eval (/home/linuxbrew/.linuxbrew/bin/brew shellenv)
|
set -l brew_cache "$HOME/.cache/brew_env.fish"
|
||||||
|
set -l brew_bin "/home/linuxbrew/.linuxbrew/bin/brew"
|
||||||
|
|
||||||
|
# Regenerate cache if: doesn't exist, >7 days old, or brew binary is newer
|
||||||
|
if not test -f "$brew_cache"; \
|
||||||
|
or test (math (date +%s) - (stat -c %Y "$brew_cache" 2>/dev/null || echo 0)) -gt 604800; \
|
||||||
|
or test "$brew_bin" -nt "$brew_cache"
|
||||||
|
mkdir -p (dirname "$brew_cache")
|
||||||
|
$brew_bin shellenv > "$brew_cache" 2>/dev/null
|
||||||
|
end
|
||||||
|
|
||||||
|
test -f "$brew_cache" && source "$brew_cache"
|
||||||
end
|
end
|
||||||
|
|
||||||
set -gx PYENV_ROOT $HOME/.pyenv
|
set -gx PYENV_ROOT $HOME/.pyenv
|
||||||
|
|
||||||
# bun
|
# bun
|
||||||
set -gx BUN_INSTALL $HOME/.bun
|
set -gx BUN_INSTALL $HOME/.bun
|
||||||
fish_add_path $BUN_INSTALL/bin
|
set -a paths_to_add $BUN_INSTALL/bin
|
||||||
# Note: Bun's _bun file is bash-specific, Fish completions handled separately
|
# Note: Bun's _bun file is bash-specific, Fish completions handled separately
|
||||||
|
|
||||||
# jenv (Java version manager)
|
# jenv (add to path list for later batch add)
|
||||||
if test -d $HOME/.jenv/bin
|
if test -d $HOME/.jenv/bin
|
||||||
fish_add_path $HOME/.jenv/bin
|
set -a paths_to_add $HOME/.jenv/bin
|
||||||
if command -q jenv
|
|
||||||
jenv init - fish | source
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# pnpm
|
# pnpm
|
||||||
set -gx PNPM_HOME $HOME/.local/share/pnpm
|
set -gx PNPM_HOME $HOME/.local/share/pnpm
|
||||||
if not contains $PNPM_HOME $PATH
|
set -a paths_to_add $PNPM_HOME
|
||||||
fish_add_path $PNPM_HOME
|
|
||||||
end
|
|
||||||
|
|
||||||
# spicetify
|
# spicetify
|
||||||
if test -d $HOME/.spicetify
|
test -d $HOME/.spicetify && set -a paths_to_add $HOME/.spicetify
|
||||||
fish_add_path $HOME/.spicetify
|
|
||||||
end
|
|
||||||
|
|
||||||
# pulumi
|
# pulumi
|
||||||
if test -d $HOME/.pulumi/bin
|
test -d $HOME/.pulumi/bin && set -a paths_to_add $HOME/.pulumi/bin
|
||||||
fish_add_path $HOME/.pulumi/bin
|
|
||||||
end
|
|
||||||
|
|
||||||
# dotnet
|
# dotnet
|
||||||
if test -d $HOME/.dotnet
|
if test -d $HOME/.dotnet
|
||||||
set -gx DOTNET_ROOT $HOME/.dotnet
|
set -gx DOTNET_ROOT $HOME/.dotnet
|
||||||
fish_add_path $DOTNET_ROOT
|
set -a paths_to_add $DOTNET_ROOT $DOTNET_ROOT/tools
|
||||||
fish_add_path $DOTNET_ROOT/tools
|
end
|
||||||
|
|
||||||
|
# Batch add all collected paths (single PATH reconstruction instead of 17+ calls)
|
||||||
|
test -n "$paths_to_add[1]" && fish_add_path $paths_to_add
|
||||||
|
|
||||||
|
# Post-PATH initialization for tools that need commands available
|
||||||
|
if test -d $HOME/.jenv/bin; and command -q jenv
|
||||||
|
jenv init - fish | source
|
||||||
end
|
end
|
||||||
|
|
||||||
# Note: Aliases are defined in Fish-native format in ~/.config/fish/conf.d/abbr.fish
|
# Note: Aliases are defined in Fish-native format in ~/.config/fish/conf.d/abbr.fish
|
||||||
|
|||||||
@@ -28,7 +28,23 @@ if [ -d "$HOME/.deno" ]; then
|
|||||||
. "$HOME/.deno/env" # Deno
|
. "$HOME/.deno/env" # Deno
|
||||||
fi
|
fi
|
||||||
. "$HOME/.cargo/env" # Rustup + Cargo + Cargo-installed tools
|
. "$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 rbenv &> /dev/null && eval "$(rbenv init -)" # rbenv for Ruby
|
||||||
command -v chatgpt &> /dev/null && . <(chatgpt --set-completions {{ .shell -}}) # chatgpt completions
|
command -v chatgpt &> /dev/null && . <(chatgpt --set-completions {{ .shell -}}) # chatgpt completions
|
||||||
{{ if eq .shell "bash" -}}
|
{{ if eq .shell "bash" -}}
|
||||||
@@ -50,7 +66,6 @@ fi
|
|||||||
# bun
|
# bun
|
||||||
export BUN_INSTALL="$HOME/.bun"
|
export BUN_INSTALL="$HOME/.bun"
|
||||||
export PATH="$BUN_INSTALL/bin:$PATH"
|
export PATH="$BUN_INSTALL/bin:$PATH"
|
||||||
[ -s "$HOME/.bun/_bun" ] && source "$HOME/.bun/_bun"
|
|
||||||
|
|
||||||
# java version manager
|
# java version manager
|
||||||
if [ -d $HOME/.jenv/bin ]; then
|
if [ -d $HOME/.jenv/bin ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user