Files
dotfiles/shell/paths.zsh
T
David F GliddenandClaude 9d9c0ad241 🦇 Batman returns with enhanced powers
- Enhanced man function opens in new window with bat + Nord theme
- Batman alias now uses enhanced man function for muscle memory
- Added license scanner utility
- Fixed shell loading to use only dotfiles versions
- Added dotfiles/bin to PATH for custom scripts
- Removed legacy .zsh loading conflicts
- Fixed bat path issue for new shell contexts

Following prime directive: respecting muscle memory while enhancing capability

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-28 23:34:11 +02:00

86 lines
3.0 KiB
Bash

# ░█▀█░█▀█░▀█▀░█░█░█▀▀
# ░█▀▀░█▀█░░█░░█▀█░▀▀█
# ░▀░░░▀░▀░░▀░░▀░▀░▀▀▀
# Intelligent PATH management with existence checking and deduplication
# Ensure we have a clean slate for PATH manipulation
# Remove duplicates automatically (zsh-specific)
if [[ -n "$ZSH_VERSION" ]]; then
typeset -U path PATH
fi
# Define potential paths in priority order
declare -a potential_paths=(
"$HOME/dotfiles/bin" # Dotfiles scripts
"$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