dotfile for cappyzawa (using macOS).
$ xcode-select --install
$ git clone https://github.com/cappyzawa/dotfiles.git ~/.dotfiles
$ make all
This dotfiles includes a flexible PATH management system (.zsh/05_path_manager.zsh
) that solves common issues with shell configuration:
# Add directory to PATH (highest priority)
path_add /path/to/bin
# Add directory with lower priority
path_add /path/to/bin append
# Add paths with variables (supports dynamic resolution)
path_add '$CUSTOM_ROOT/bin'
# Remove from PATH
path_remove /path/to/bin
# Debug current PATH state (shows managed vs system paths)
path_debug
- Flexibility: Variables are resolved dynamically, so changing
$CUSTOM_ROOT
works correctly - Priority Control: Later additions override earlier ones properly
- Automatic Deduplication: No duplicate entries in PATH
- Existence Checking: Only existing directories are added
- Debug Support: Visual debugging with
path_debug
command (✓ = managed paths)
When adding new development tools, use this pattern:
# In your custom zsh files (e.g., .zsh/80_custom.zsh)
export TOOL_ROOT=${TOOL_ROOT:-$HOME/.tool}
path_add '$TOOL_ROOT/bin'
This ensures the tool's PATH works correctly even if TOOL_ROOT
is changed later.
- Fast Startup: ~15ms shell startup time with lazy loading (94% improvement from 250ms)
- Command Caching: Repeated command existence checks are cached
- Lazy Loading System: Heavy tools load on first command execution
- Optimized PATH Setup: Essential paths in
.zshenv
, detailed paths via afx snippet
.zshenv
: Environment variables + essential PATH (~/bin, aqua).zprofile
: afx lazy loading hook registration + Homebrew initialization.zshrc
: Minimal configuration (colors setup + local overrides)- On first command (precmd hook):
afx init
executes, loading all local scripts, zsh plugins, and.zsh/hooks/
New tools can be easily added to the lazy loading system by creating hook files in .zsh/hooks/
:
# .zsh/hooks/newtool.zsh
_lazy_load_newtool() {
eval "$(newtool init)"
unfunction _lazy_load_newtool
}
if command -v newtool &> /dev/null; then
function _newtool_hook() {
_lazy_load_newtool
unfunction _newtool_hook
}
autoload -Uz add-zsh-hook
add-zsh-hook precmd _newtool_hook
fi
Files placed in .zsh/hooks/
are automatically loaded by afx (via local.yaml configuration). This pattern:
- Only registers hooks for available commands
- Removes hooks after first execution
- Provides significant startup performance improvements
- Homebrew: System tools and GUI applications
- Aqua: Development CLI tools with version management
- afx: Zsh plugins and GitHub CLI extensions