🎯 Comprehensive refinement addressing durability and maintainability: **Modular Architecture:** - environment.zsh: Centralized environment variables with XDG compliance - paths.zsh: Intelligent PATH management with existence checking - aliases.zsh: Enhanced aliases with tool fallbacks and context awareness - functions.zsh: Sophisticated functions with error handling and recovery - .zshrc: Clean main config with graceful degradation **Key Improvements:** - ✅ Fixed PATH duplication and made portable - ✅ Added graceful dependency handling throughout - ✅ Enhanced vault/chamber/work context integration - ✅ Comprehensive error recovery in sysupdate() - ✅ Intelligent tool detection and fallbacks - ✅ Performance optimizations for different shell modes **Philosophy Applied:** - μέτρον (measure): Right amount of features without bloat - συμμετρία (proportion): Balanced modular structure - πρόσφορον (fitting): Portable, maintainable, testable **Testing:** - Syntax validation for all modules - Function loading verification - Isolated test environment - Ready for production deployment 🤖 Generated with Claude Code (https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
82 lines
2.9 KiB
Bash
82 lines
2.9 KiB
Bash
# ░█▀█░█▀█░▀█▀░█░█░█▀▀
|
|
# ░█▀▀░█▀█░░█░░█▀█░▀▀█
|
|
# ░▀░░░▀░▀░░▀░░▀░▀░▀▀▀
|
|
|
|
# Intelligent PATH management with existence checking and deduplication
|
|
|
|
# Ensure we have a clean slate for PATH manipulation
|
|
typeset -U path PATH # Remove duplicates automatically
|
|
|
|
# Define potential paths in priority order
|
|
declare -a potential_paths=(
|
|
"$HOME/bin" # Personal scripts
|
|
"$HOME/.local/bin" # User-installed binaries
|
|
"/opt/homebrew/bin" # Homebrew (Apple Silicon)
|
|
"/opt/homebrew/sbin" # Homebrew system binaries
|
|
"/usr/local/bin" # Homebrew (Intel)
|
|
"/usr/local/sbin" # System binaries
|
|
"/opt/homebrew/opt/python@3.13/libexec/bin" # Python 3.13
|
|
"/opt/homebrew/opt/python@3.12/libexec/bin" # Python 3.12 (fallback)
|
|
"$HOME/.cargo/bin" # Rust binaries
|
|
"/opt/homebrew/opt/gnu-sed/libexec/gnubin" # GNU sed
|
|
"/opt/homebrew/opt/gnu-tar/libexec/gnubin" # GNU tar
|
|
"/opt/homebrew/opt/coreutils/libexec/gnubin" # GNU coreutils
|
|
)
|
|
|
|
# Build PATH intelligently
|
|
build_path() {
|
|
local new_paths=()
|
|
|
|
# Add existing paths that we want to keep
|
|
for existing_path in "${path[@]}"; do
|
|
case "$existing_path" in
|
|
# Skip paths we're going to add explicitly
|
|
"$HOME/bin"|"$HOME/.local/bin"|"/opt/homebrew"*|"/usr/local"*|"$HOME/.cargo/bin") ;;
|
|
# Keep system paths and others
|
|
*) new_paths+=("$existing_path") ;;
|
|
esac
|
|
done
|
|
|
|
# Add our curated paths (only if they exist)
|
|
for check_path in "${potential_paths[@]}"; do
|
|
if [[ -d "$check_path" ]]; then
|
|
new_paths=("$check_path" "${new_paths[@]}")
|
|
fi
|
|
done
|
|
|
|
# Rebuild PATH
|
|
path=("${new_paths[@]}")
|
|
}
|
|
|
|
# Execute PATH building
|
|
build_path
|
|
|
|
# Verify critical tools are accessible
|
|
verify_path() {
|
|
local critical_tools=(git zsh python3 brew)
|
|
local missing_tools=()
|
|
|
|
for tool in "${critical_tools[@]}"; do
|
|
if ! command -v "$tool" >/dev/null 2>&1; then
|
|
missing_tools+=("$tool")
|
|
fi
|
|
done
|
|
|
|
if (( ${#missing_tools[@]} > 0 )); then
|
|
echo "⚠️ Missing critical tools: ${missing_tools[*]}"
|
|
echo "💡 Consider running: brew install ${missing_tools[*]}"
|
|
fi
|
|
}
|
|
|
|
# Run verification only in interactive shells
|
|
[[ $- == *i* ]] && verify_path
|
|
|
|
# MANPATH configuration for enhanced man pages
|
|
if [[ -d "/opt/homebrew/share/man" ]]; then
|
|
export MANPATH="/opt/homebrew/share/man:$MANPATH"
|
|
fi
|
|
|
|
# Info path for GNU info pages
|
|
if [[ -d "/opt/homebrew/share/info" ]]; then
|
|
export INFOPATH="/opt/homebrew/share/info:$INFOPATH"
|
|
fi |