Loading...
Loading...
Manage and troubleshoot PATH configuration in zsh. Use when adding tools to PATH (bun, nvm, Python venv, cargo, go), diagnosing "command not found" errors, validating PATH entries, or organizing shell configuration in .zshrc and .zshrc.local files.
npx skill4agent add julianobarbosa/claude-code-skills zsh-path-skill# List all PATH entries
echo $PATH | tr ':' '\n'
# Check if specific command is in PATH
which bun 2>/dev/null || echo "bun not found in PATH"
# Find where a command is installed
command -v node
type -a python# Check for broken/non-existent PATH entries
echo $PATH | tr ':' '\n' | while read p; do
[[ -d "$p" ]] || echo "MISSING: $p"
done
# Check for duplicate PATH entries
echo $PATH | tr ':' '\n' | sort | uniq -d# Add to .zshrc
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"~/.bun/bin/bun# Add to .zshrc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"~/.nvm/# Add to .zshrc for global tools venv
export PATH="$HOME/.venv/tools3/bin:$PATH"
# For pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"# Add to .zshrc
export PATH="$HOME/.cargo/bin:$PATH"# Add to .zshrc
export GOPATH="$HOME/go"
export PATH="$GOPATH/bin:$PATH"# Intel Mac
export PATH="/usr/local/bin:$PATH"
# Apple Silicon Mac
export PATH="/opt/homebrew/bin:$PATH"
eval "$(/opt/homebrew/bin/brew shellenv)"# User-local binaries
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/bin:$PATH"# ===== ZSH-TOOL MANAGED SECTION BEGIN =====
# Team-wide PATH modifications
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/bin:$PATH"
# Bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
# NVM
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# ===== ZSH-TOOL MANAGED SECTION END =====
# Load local customizations
[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local# Machine-specific tools
export PATH="/opt/custom-tool/bin:$PATH"
# Personal integrations
if command -v atuin >/dev/null 2>&1; then
eval "$(atuin init zsh)"
fi# This order means ~/.local/bin takes priority over system bins
export PATH="$HOME/.local/bin:/usr/local/bin:/usr/bin:/bin"~/.local/bin~/bin/usr/local/bin/usr/bin# 1. Find where tool was installed
ls -la ~/.bun/bin/bun 2>/dev/null
ls -la ~/.cargo/bin/rustc 2>/dev/null
ls -la ~/.nvm/versions/node/*/bin/node 2>/dev/null
# 2. Check if PATH includes the directory
echo $PATH | tr ':' '\n' | grep -E "(bun|cargo|nvm)"
# 3. Add missing PATH entry to .zshrc
# 4. Reload shell
source ~/.zshrc
# or
exec $SHELL# Check which file sets the variable
grep -r "export PATH" ~/.zshrc ~/.zshrc.local ~/.zprofile 2>/dev/null
# Source the correct file
source ~/.zshrc
# Or start fresh shell
exec $SHELL# Debug startup
zsh -x 2>&1 | head -100
# Check for errors in specific config
bash -n ~/.zshrc# Remove duplicates (add to .zshrc)
typeset -U PATH path# Reload configuration
source ~/.zshrc
# Verify tool is accessible
which bun && bun --version
which node && node --version
command -v nvm && nvm --version
# Verify PATH includes new entries
echo $PATH | tr ':' '\n' | grep -E "(bun|nvm|venv)"| Tool | PATH Entry | Check Command |
|---|---|---|
| bun | | |
| nvm | | |
| cargo | | |
| go | | |
| pyenv | | |
| brew (ARM) | | |
| brew (Intel) | | |
# Only add if directory exists
[[ -d "$HOME/.bun/bin" ]] && export PATH="$HOME/.bun/bin:$PATH"
# Only add if command not already available
command -v bun >/dev/null || export PATH="$HOME/.bun/bin:$PATH"# Lazy load nvm (faster shell startup)
lazy_load_nvm() {
unset -f nvm node npm npx
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
}
nvm() { lazy_load_nvm && nvm "$@"; }
node() { lazy_load_nvm && node "$@"; }
npm() { lazy_load_nvm && npm "$@"; }
npx() { lazy_load_nvm && npx "$@"; }