From 546e43fc641d6d1e4d3b0611a3266295925f8668 Mon Sep 17 00:00:00 2001 From: David F Glidden Date: Sun, 27 Jul 2025 14:01:23 +0200 Subject: [PATCH] Refactor shell configuration following prime directive principles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ๐ŸŽฏ 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 --- scripts/symlinks.sh | 18 +- scripts/test-shell-config.sh | 126 ++++++++++++ shell/.zsh-plugins.txt | 19 ++ shell/.zshrc | 193 +++++++++++++++++++ shell/aliases.zsh | 182 ++++++++++++++++++ shell/environment.zsh | 64 +++++++ shell/functions.zsh | 361 +++++++++++++++++++++++++++++++++++ shell/paths.zsh | 82 ++++++++ 8 files changed, 1033 insertions(+), 12 deletions(-) create mode 100755 scripts/test-shell-config.sh create mode 100644 shell/.zsh-plugins.txt create mode 100644 shell/.zshrc create mode 100644 shell/aliases.zsh create mode 100644 shell/environment.zsh create mode 100644 shell/functions.zsh create mode 100644 shell/paths.zsh diff --git a/scripts/symlinks.sh b/scripts/symlinks.sh index e75dc52..68de258 100755 --- a/scripts/symlinks.sh +++ b/scripts/symlinks.sh @@ -40,11 +40,14 @@ link_file() { # Shell configurations echo -e "${YELLOW}Linking shell configurations...${NC}" -link_file "$DOTFILES_DIR/.zshrc" "$HOME/.zshrc" +link_file "$DOTFILES_DIR/shell/.zshrc" "$HOME/.zshrc" link_file "$DOTFILES_DIR/.gitconfig" "$HOME/.gitconfig" link_file "$DOTFILES_DIR/.vimrc" "$HOME/.vimrc" link_file "$DOTFILES_DIR/.npmrc" "$HOME/.npmrc" +# Link plugin manifest +link_file "$DOTFILES_DIR/shell/.zsh-plugins.txt" "$HOME/.zsh-plugins.txt" + # SSH config (template only - user must customize) if [ -f "$DOTFILES_DIR/ssh/config.example" ] && [ ! -f "$HOME/.ssh/config" ]; then echo -e "${YELLOW}Creating SSH config from template...${NC}" @@ -89,17 +92,8 @@ if [ -f "$DOTFILES_DIR/.mackup.cfg" ]; then link_file "$DOTFILES_DIR/.mackup.cfg" "$HOME/.mackup.cfg" fi -# Shell enhancements -echo -e "${YELLOW}Setting up shell enhancements...${NC}" -if [ -f "$DOTFILES_DIR/shell/history-sync.zsh" ]; then - # Add source line to .zshrc if not already present - if ! grep -q "history-sync.zsh" "$HOME/.zshrc" 2>/dev/null; then - echo "" >> "$HOME/.zshrc" - echo "# History sync and enhancements" >> "$HOME/.zshrc" - echo "source $DOTFILES_DIR/shell/history-sync.zsh" >> "$HOME/.zshrc" - echo -e "${GREEN}โœ“ Added history sync to .zshrc${NC}" - fi -fi +# Shell enhancements are now integrated into the main .zshrc +echo -e "${GREEN}โœ“ Shell enhancements integrated into main configuration${NC}" echo "" echo -e "${GREEN}Symlinks created successfully! ๐Ÿ”—${NC}" diff --git a/scripts/test-shell-config.sh b/scripts/test-shell-config.sh new file mode 100755 index 0000000..784b5c2 --- /dev/null +++ b/scripts/test-shell-config.sh @@ -0,0 +1,126 @@ +#!/usr/bin/env bash +# Test refined shell configuration before deployment + +set -euo pipefail + +# Colors +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +RED='\033[0;31m' +BLUE='\033[0;34m' +NC='\033[0m' + +DOTFILES_DIR="$HOME/dotfiles" +TEST_DIR="/tmp/dotfiles-test-$$" + +echo -e "${BLUE}Testing refined shell configuration...${NC}" + +# Create test environment +mkdir -p "$TEST_DIR" +export HOME="$TEST_DIR" + +echo -e "${YELLOW}Setting up test environment...${NC}" + +# Copy configuration files +cp -r "$DOTFILES_DIR/shell" "$TEST_DIR/" +mkdir -p "$TEST_DIR/.config" + +# Create minimal test environment +cat > "$TEST_DIR/.zshrc" << 'EOF' +# Test configuration +export DOTFILES_PATH="$HOME/dotfiles" +export VAULT_PATH="$HOME/test-vault" +export CHAMBER_PATH="$HOME/test-chamber" +export WORK_PATH="$HOME/test-work" + +# Source our refined config +source "$HOME/shell/.zshrc" +EOF + +# Create fake dotfiles structure +mkdir -p "$TEST_DIR/dotfiles" +cp -r "$DOTFILES_DIR/shell" "$TEST_DIR/dotfiles/" + +echo -e "${YELLOW}Running syntax checks...${NC}" + +# Test zsh syntax +if zsh -n "$TEST_DIR/shell/.zshrc"; then + echo -e "${GREEN}โœ“ Main .zshrc syntax valid${NC}" +else + echo -e "${RED}โŒ Main .zshrc syntax error${NC}" + exit 1 +fi + +# Test individual modules +modules=( + "environment.zsh" + "paths.zsh" + "aliases.zsh" + "functions.zsh" +) + +for module in "${modules[@]}"; do + if zsh -n "$TEST_DIR/shell/$module"; then + echo -e "${GREEN}โœ“ $module syntax valid${NC}" + else + echo -e "${RED}โŒ $module syntax error${NC}" + exit 1 + fi +done + +echo -e "${YELLOW}Testing function loading...${NC}" + +# Test in actual zsh environment +zsh -c " +export HOME='$TEST_DIR' +source '$TEST_DIR/.zshrc' 2>/dev/null +echo 'Configuration loaded successfully' + +# Test that functions are defined +if typeset -f sysupdate >/dev/null; then + echo 'โœ“ sysupdate function loaded' +else + echo 'โŒ sysupdate function missing' + exit 1 +fi + +if typeset -f deep_clean >/dev/null; then + echo 'โœ“ deep_clean function loaded' +else + echo 'โŒ deep_clean function missing' + exit 1 +fi + +# Test aliases +if alias ls >/dev/null 2>&1; then + echo 'โœ“ Aliases loaded' +else + echo 'โŒ Aliases not loaded' + exit 1 +fi + +# Test PATH management +if [[ -n \"\$PATH\" ]]; then + echo 'โœ“ PATH configured' +else + echo 'โŒ PATH not configured' + exit 1 +fi +" + +if [[ $? -eq 0 ]]; then + echo -e "${GREEN}โœ… All tests passed!${NC}" +else + echo -e "${RED}โŒ Tests failed${NC}" + exit 1 +fi + +# Cleanup +rm -rf "$TEST_DIR" + +echo -e "${BLUE}Configuration ready for deployment!${NC}" +echo "" +echo "To deploy:" +echo "1. Backup current config: cp ~/.zshrc ~/.zshrc.backup" +echo "2. Run symlink script: ~/dotfiles/scripts/symlinks.sh" +echo "3. Restart shell: exec zsh" \ No newline at end of file diff --git a/shell/.zsh-plugins.txt b/shell/.zsh-plugins.txt new file mode 100644 index 0000000..ac3758b --- /dev/null +++ b/shell/.zsh-plugins.txt @@ -0,0 +1,19 @@ +# Antidote plugin manifest +# Each line represents a plugin to be loaded by antidote + +# Core functionality +romkatv/powerlevel10k +zsh-users/zsh-autosuggestions +zsh-users/zsh-syntax-highlighting +zsh-users/zsh-completions + +# Enhanced navigation and search +junegunn/fzf path:shell/completion.zsh +junegunn/fzf path:shell/key-bindings.zsh + +# Git integration +wfxr/forgit + +# Additional utilities +zdharma-continuum/fast-syntax-highlighting +MichaelAquilina/zsh-you-should-use \ No newline at end of file diff --git a/shell/.zshrc b/shell/.zshrc new file mode 100644 index 0000000..f3b4b54 --- /dev/null +++ b/shell/.zshrc @@ -0,0 +1,193 @@ +# โ–‘โ–‘โ–‘โ–‘โ–€โ–€โ–ˆโ–‘โ–ˆโ–€โ–€โ–‘โ–ˆโ–‘โ–ˆโ–‘โ–ˆโ–€โ–„โ–‘โ–ˆโ–€โ–€ +# โ–‘โ–‘โ–‘โ–‘โ–„โ–€โ–‘โ–‘โ–€โ–€โ–ˆโ–‘โ–ˆโ–€โ–ˆโ–‘โ–ˆโ–€โ–„โ–‘โ–ˆโ–‘โ–‘ +# โ–‘โ–€โ–‘โ–‘โ–€โ–€โ–€โ–‘โ–€โ–€โ–€โ–‘โ–€โ–‘โ–€โ–‘โ–€โ–‘โ–€โ–‘โ–€โ–€โ–€ +# Refined shell configuration following durability principles +# ASCII art: TextKool (https://textkool.com/en) "Font: Pagga" + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# PERFORMANCE & EARLY INITIALIZATION +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Enable Powerlevel10k instant prompt (must be near top) +if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then + source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" +fi + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# CORE ENVIRONMENT SETUP +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Source modular configuration files +local config_files=( + "$HOME/dotfiles/shell/environment.zsh" + "$HOME/dotfiles/shell/paths.zsh" +) + +for config_file in "${config_files[@]}"; do + [[ -f "$config_file" ]] && source "$config_file" +done + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# PLUGIN MANAGEMENT +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Antidote plugin manager with graceful fallback +if [[ -f "/opt/homebrew/share/antidote/antidote.zsh" ]]; then + source /opt/homebrew/share/antidote/antidote.zsh + + # Load plugins from manifest + local plugin_file="$HOME/dotfiles/shell/.zsh-plugins.txt" + if [[ -f "$plugin_file" ]]; then + antidote load < "$plugin_file" + else + echo "โš ๏ธ Plugin manifest not found: $plugin_file" + fi +else + echo "โš ๏ธ Antidote not found. Install with: brew install antidote" +fi + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# PROMPT CONFIGURATION +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Powerlevel10k configuration +[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh +# Run 'p10k configure' to reconfigure prompt + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# SHELL BEHAVIOR & OPTIONS +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Directory navigation +setopt auto_cd # Type directory name to cd into it +setopt auto_pushd # Make cd push old directory onto stack +setopt pushd_ignore_dups # Don't push duplicates onto stack +setopt pushd_minus # Make pushd work like cd + +# Command correction and expansion +setopt correct # Spelling correction for commands +setopt correct_all # Spelling correction for arguments +setopt interactive_comments # Allow comments in interactive shell +setopt extended_glob # Enable extended globbing +setopt glob_dots # Don't require leading . in filename to be matched + +# History configuration (extended) +setopt extended_history # Record timestamp and duration +setopt hist_expire_dups_first # Expire duplicates first +setopt hist_ignore_all_dups # Don't record duplicates +setopt hist_ignore_space # Don't record commands starting with space +setopt hist_verify # Show command before executing from history +setopt inc_append_history # Add commands immediately +setopt share_history # Share history between sessions +setopt hist_reduce_blanks # Remove superfluous blanks + +# Job control +setopt auto_resume # Single word commands can resume jobs +setopt long_list_jobs # List jobs in long format +setopt notify # Report status of background jobs immediately + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# COMPLETION SYSTEM +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Initialize completion system +autoload -Uz compinit +compinit + +# Completion options +setopt complete_in_word # Complete from both ends of word +setopt always_to_end # Move cursor to end after completion +setopt auto_menu # Show completion menu on successive tab +setopt auto_list # Automatically list choices on ambiguous completion +setopt auto_param_slash # Add trailing slash for directory completions + +# Completion styling +zstyle ':completion:*' menu select +zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" +zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*' + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# TOOL INTEGRATIONS +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# FZF integration +if [[ -f ~/.fzf.zsh ]]; then + source ~/.fzf.zsh +elif command -v fzf >/dev/null; then + # Manual key bindings if fzf is available but not set up + eval "$(fzf --zsh)" 2>/dev/null || true +fi + +# Zoxide integration (smart cd) +if command -v zoxide >/dev/null; then + eval "$(zoxide init zsh)" +fi + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# CUSTOM FUNCTIONS & ALIASES +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Load enhanced functions and aliases +local shell_files=( + "$HOME/dotfiles/shell/functions.zsh" + "$HOME/dotfiles/shell/aliases.zsh" +) + +for shell_file in "${shell_files[@]}"; do + if [[ -f "$shell_file" ]]; then + source "$shell_file" + else + echo "โš ๏ธ Shell configuration missing: $shell_file" + fi +done + +# Legacy support (if old files exist) +[[ -f "$HOME/.zsh/aliases.zsh" ]] && source "$HOME/.zsh/aliases.zsh" +[[ -f "$HOME/.zsh/functions.zsh" ]] && source "$HOME/.zsh/functions.zsh" + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# CONTEXT AWARENESS +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Detect and set initial context +detect_context + +# Display context-aware welcome message (interactive shells only) +if [[ $- == *i* ]] && [[ -z "$VSCODE_INJECTION" ]]; then + case "$CURRENT_CONTEXT" in + "work") echo "๐Ÿข Work context activated" ;; + "chamber") echo "๐Ÿ”ฎ Chamber context activated" ;; + "vault") echo "๐Ÿ“š Vault context activated" ;; + "dotfiles") echo "โš™๏ธ Dotfiles context activated" ;; + esac +fi + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# PERFORMANCE OPTIMIZATION +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Fast mode for non-interactive shells +[[ $- != *i* ]] && unsetopt zle && return + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# LOCAL CUSTOMIZATIONS +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Machine-specific configurations +[[ -f "$HOME/.zshrc.local" ]] && source "$HOME/.zshrc.local" + +# Development environment configurations +[[ -f "$HOME/.env.local" ]] && source "$HOME/.env.local" + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# LEGACY & MIGRATION SUPPORT +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Temporary: Handle pipx path duplication (remove after migration) +typeset -U path PATH + +# Note: This configuration follows the ฮผฮญฯ„ฯฮฟฮฝ principle +# - Each section has clear purpose and boundaries +# - Graceful degradation when tools are missing +# - Performance considerations for different use cases +# - Modular structure for maintainability \ No newline at end of file diff --git a/shell/aliases.zsh b/shell/aliases.zsh new file mode 100644 index 0000000..de2bafe --- /dev/null +++ b/shell/aliases.zsh @@ -0,0 +1,182 @@ +# โ–‘โ–ˆโ–€โ–ˆโ–‘โ–ˆโ–‘โ–‘โ–‘โ–€โ–ˆโ–€โ–‘โ–ˆโ–€โ–ˆโ–‘โ–ˆโ–€โ–€โ–‘โ–ˆโ–€โ–€โ–‘โ–ˆโ–€โ–€ +# โ–‘โ–ˆโ–€โ–ˆโ–‘โ–ˆโ–‘โ–‘โ–‘โ–‘โ–ˆโ–‘โ–‘โ–ˆโ–€โ–ˆโ–‘โ–€โ–€โ–ˆโ–‘โ–ˆโ–€โ–€โ–‘โ–€โ–€โ–ˆ +# โ–‘โ–€โ–‘โ–€โ–‘โ–€โ–€โ–€โ–‘โ–€โ–€โ–€โ–‘โ–€โ–‘โ–€โ–‘โ–€โ–€โ–€โ–‘โ–€โ–€โ–€โ–‘โ–€โ–€โ–€ + +# Enhanced aliases with intelligent fallbacks and context awareness + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# I. NAVIGATION & LISTING +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Enhanced navigation with consistent patterns +alias ..="cd .." +alias ...="cd ../.." +alias ....="cd ../../.." +alias .....="cd ../../../.." +alias -- -="cd -" # Go back to previous directory + +# Context-aware directory shortcuts +alias dl="cd ~/Downloads" +alias dt="cd ~/Desktop" +alias docs="cd ~/Documents" +alias vault="cd '$VAULT_PATH'" +alias chamber="cd '$CHAMBER_PATH'" +alias work="cd '$WORK_PATH'" +alias dotfiles="cd '$DOTFILES_PATH'" + +# Vault-specific navigation +alias daily="cd '$VAULT_PATH/01. Daily'" +alias notes="cd '$VAULT_PATH/08. Notes'" +alias projects="cd '$VAULT_PATH/06. Projects'" +alias templates="cd '$VAULT_PATH/98. Templates'" + +# Enhanced listing with eza (fallback to ls) +if command -v eza >/dev/null 2>&1; then + alias ls='eza --color=auto --group-directories-first --icons' + alias ll='eza -lgh --git --time-style=relative' + alias la='eza -la --git --time-style=relative' + alias lt='eza --tree --level=2 --icons --git' + alias ltree='eza --tree --icons --git' + alias lx='eza -lgh --sort=extension --git' + alias lk='eza -lgh --sort=size --git' + alias lt='eza -lgh --sort=modified --git' +else + # Fallback to standard ls with colors + alias ls='ls --color=auto' + alias ll='ls -lh' + alias la='ls -lah' + alias lt='ls -lt' +fi + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# II. GIT & VERSION CONTROL +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +alias gs='git status' +alias ga='git add' +alias gc='git commit' +alias gp='git push' +alias gl='git pull' +alias gd='git diff' +alias gb='git branch' +alias gco='git checkout' +alias glog='git log --oneline --graph --decorate' + +# Enhanced git aliases +alias gss='git status --short' +alias gaa='git add --all' +alias gcm='git commit -m' +alias gcam='git commit -am' +alias gundo='git reset --soft HEAD~1' +alias gclean='git clean -fd' + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# III. SEARCH & TEXT PROCESSING +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Enhanced search with ripgrep (fallback to grep) +if command -v rg >/dev/null 2>&1; then + alias grep='rg --smart-case --follow --color=always' + alias greph='rg --hidden --follow --color=always' + alias grepi='rg --ignore-case --follow --color=always' +else + alias grep='grep --color=auto' + alias grepi='grep -i --color=auto' +fi + +# Enhanced cat with bat (fallback to cat) +if command -v bat >/dev/null 2>&1; then + alias cat='bat --style=auto' + alias ccat='bat --style=plain' # Plain cat equivalent +else + alias bat='cat' +fi + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# IV. MEDIA & DOWNLOADS +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Download utilities +alias dl="curl -O" +alias yt="yt-dlp -S res,ext:mp4:m4a --recode mp4" +alias yta="yt-dlp -x --audio-format mp3" + +# Quick media info +alias mediainfo='ffprobe -v quiet -print_format json -show_format -show_streams' + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# V. SYSTEM MONITORING & NETWORK +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Network information +alias ip="dig +short myip.opendns.com @resolver1.opendns.com" +alias localip="ipconfig getifaddr en0" +alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'" + +# Speed and connectivity +alias speed="npx speed-cloudflare-cli" +alias ping="ping -c 5" +alias pingg="ping google.com" + +# System monitoring +alias cpu="top -F -R -o cpu" +alias mem="top -F -R -o rsize" +alias ports="lsof -i -P | grep LISTEN" + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# VI. MACOS SPECIFIC +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Finder and system +alias show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder" +alias hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder" +alias ql="qlmanage -p" # Quick Look from terminal +alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend" + +# Spotlight control +alias spotoff="sudo mdutil -a -i off" +alias spoton="sudo mdutil -a -i on" + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# VII. CHECKSUMS & SECURITY +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +alias verify1='openssl sha1' +alias verify256='openssl dgst -sha256' +alias verify512='openssl dgst -sha512' + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# VIII. WORKFLOW SPECIFIC +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Work context (Animal Rationis Capax) +alias arc="cd '$WORK_PATH' && claude 'Context initialization: +Please read these files in order: +1. CLAUDE.md - Project instructions and workflow triggers +2. docs/internal/collaboration-protocol.md - Our working relationship +3. docs/internal/project-memory.md - Complete development history +4. docs/chamber/workflow/MODE-1-UNIFIED.md - Current Chamber operations +5. docs/style-guide.md - Editorial guidelines and notation system + +After reading, confirm you understand the current state and are ready for today'\''s work.'" + +# Glimpse processing +alias glimpse="cd '$CHAMBER_PATH/tools/glimpse-processing' && source venv/bin/activate && python glimpse_tool.py" + +# Entertainment +alias tetris='/opt/homebrew/opt/vitetris/bin/tetris' + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# IX. MAINTENANCE & UPDATES +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# System maintenance (interactive confirmation) +alias update="read -q 'REPLY?Run full system update? (y/n) ' && echo && sysupdate || echo 'Aborted.'" +alias mrclean='sudo periodic daily weekly monthly' + +# Comprehensive cleanup +alias cleanup='deep_clean' # References function in functions.zsh + +# Quick dotfiles management +alias dotfiles-backup='$DOTFILES_PATH/bin/backup-dotfiles' +alias dotfiles-status='$DOTFILES_PATH/bin/check-app-configs' \ No newline at end of file diff --git a/shell/environment.zsh b/shell/environment.zsh new file mode 100644 index 0000000..edb4f22 --- /dev/null +++ b/shell/environment.zsh @@ -0,0 +1,64 @@ +# โ–‘โ–ˆโ–€โ–€โ–‘โ–ˆโ–€โ–ˆโ–‘โ–ˆโ–‘โ–ˆโ–‘โ–€โ–ˆโ–€โ–‘โ–ˆโ–€โ–„โ–‘โ–ˆโ–€โ–ˆโ–‘โ–ˆโ–€โ–ˆโ–‘โ–ˆโ–„โ–ˆโ–‘โ–ˆโ–€โ–€โ–‘โ–ˆโ–€โ–ˆโ–‘โ–€โ–ˆโ–€ +# โ–‘โ–ˆโ–€โ–€โ–‘โ–ˆโ–‘โ–ˆโ–‘โ–€โ–„โ–€โ–‘โ–‘โ–ˆโ–‘โ–‘โ–ˆโ–€โ–„โ–‘โ–ˆโ–‘โ–ˆโ–‘โ–ˆโ–‘โ–ˆโ–‘โ–ˆโ–‘โ–ˆโ–‘โ–ˆโ–€โ–€โ–‘โ–ˆโ–‘โ–ˆโ–‘โ–‘โ–ˆโ–‘ +# โ–‘โ–€โ–€โ–€โ–‘โ–€โ–‘โ–€โ–‘โ–‘โ–€โ–‘โ–‘โ–€โ–€โ–€โ–‘โ–€โ–‘โ–€โ–‘โ–€โ–€โ–€โ–‘โ–€โ–‘โ–€โ–‘โ–€โ–‘โ–€โ–‘โ–€โ–€โ–€โ–‘โ–€โ–‘โ–€โ–‘โ–‘โ–€โ–‘ + +# Core environment variables with graceful fallbacks + +# ๐Ÿ–‹ Preferred editors +export EDITOR="${EDITOR:-bbedit}" +export VISUAL="${VISUAL:-bbedit}" + +# ๐ŸŒ Locale settings +export LANG="${LANG:-en_US.UTF-8}" +export LC_ALL="${LC_ALL:-en_US.UTF-8}" + +# ๐Ÿ—‚ History configuration +export HISTFILE="${HISTFILE:-$HOME/.zsh_history}" +export HISTSIZE=100000 +export SAVEHIST=100000 + +# ๐Ÿง  XDG Base Directory specification +export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" +export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" +export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" +export XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}" + +# ๐Ÿ“š Vault and workspace paths +export VAULT_PATH="$HOME/Library/Mobile Documents/iCloud~md~obsidian/Documents/David, root-and-branch" +export CHAMBER_PATH="$HOME/animal-davidglidden-eu" +export WORK_PATH="$HOME/Documents/GitHub/davidglidden.github.io" +export DOTFILES_PATH="$HOME/dotfiles" + +# ๐Ÿ”ง Tool configurations +export HOMEBREW_NO_ANALYTICS=1 +export HOMEBREW_NO_INSECURE_REDIRECT=1 +export HOMEBREW_CASK_OPTS="--require-sha" + +# ๐ŸŽจ Color and display +export CLICOLOR=1 +export LSCOLORS="ExGxBxDxCxEgEdxbxgxcxd" +export GREP_OPTIONS="--color=auto" + +# ๐Ÿ Python settings +export PYTHONDONTWRITEBYTECODE=1 +export PYTHONUNBUFFERED=1 + +# ๐Ÿ“Š Performance monitoring +export TIMEFMT=$'\n================\nCPU\t%P\nuser\t%*U\nsystem\t%*S\ntotal\t%*E' + +# ๐ŸŒ“ Optional API keys (with existence checks) +[[ -f "$HOME/.env.local" ]] && source "$HOME/.env.local" + +# ๐Ÿ” Security +export GPG_TTY=$(tty) + +# ๐Ÿš€ Development context detection +detect_context() { + case "$PWD" in + "$WORK_PATH"*) export CURRENT_CONTEXT="work" ;; + "$CHAMBER_PATH"*) export CURRENT_CONTEXT="chamber" ;; + "$VAULT_PATH"*) export CURRENT_CONTEXT="vault" ;; + "$DOTFILES_PATH"*) export CURRENT_CONTEXT="dotfiles" ;; + *) export CURRENT_CONTEXT="personal" ;; + esac +} \ No newline at end of file diff --git a/shell/functions.zsh b/shell/functions.zsh new file mode 100644 index 0000000..73947e4 --- /dev/null +++ b/shell/functions.zsh @@ -0,0 +1,361 @@ +# โ–‘โ–ˆโ–€โ–€โ–‘โ–ˆโ–‘โ–ˆโ–‘โ–ˆโ–€โ–ˆโ–‘โ–ˆโ–€โ–€โ–‘โ–€โ–ˆโ–€โ–‘โ–€โ–ˆโ–€โ–‘โ–ˆโ–€โ–ˆโ–‘โ–ˆโ–€โ–ˆโ–‘โ–ˆโ–€โ–€ +# โ–‘โ–ˆโ–€โ–€โ–‘โ–ˆโ–‘โ–ˆโ–‘โ–ˆโ–‘โ–ˆโ–‘โ–ˆโ–‘โ–‘โ–‘โ–‘โ–ˆโ–‘โ–‘โ–‘โ–ˆโ–‘โ–‘โ–ˆโ–‘โ–ˆโ–‘โ–ˆโ–‘โ–ˆโ–‘โ–€โ–€โ–ˆ +# โ–‘โ–€โ–‘โ–‘โ–‘โ–€โ–€โ–€โ–‘โ–€โ–‘โ–€โ–‘โ–€โ–€โ–€โ–‘โ–‘โ–€โ–‘โ–‘โ–€โ–€โ–€โ–‘โ–€โ–€โ–€โ–‘โ–€โ–‘โ–€โ–‘โ–€โ–€โ–€ + +# Sophisticated shell functions following durability principles + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# I. SYSTEM MAINTENANCE & UPDATES +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Enhanced system update with error handling and rollback capability +sysupdate() { + local start_time=$(date +%s) + local backup_dir="$HOME/.system-snapshots/$(date +%Y%m%d_%H%M%S)" + + echo "๐Ÿ”ง Starting comprehensive system update at $(date)" + + # Ensure sudo credentials and create backup point + if ! sudo -vn 2>/dev/null; then + echo "๐Ÿ”’ sudo authentication required..." + sudo -v || return 1 + fi + + mkdir -p "$backup_dir" + + # Create restore point + echo "๐Ÿ’พ Creating system snapshot..." + brew list > "$backup_dir/brew_before.txt" 2>/dev/null || true + cp "$HOME/.zshrc" "$backup_dir/" 2>/dev/null || true + + # macOS updates with error handling + echo "๐ŸŽ Updating macOS Software..." + if ! sudo softwareupdate -i -a; then + echo "โš ๏ธ macOS updates had issues - check manually" + fi + + # Homebrew updates with verification + echo "๐Ÿบ Updating Homebrew packages..." + if ! (brew update && brew upgrade); then + echo "โŒ Homebrew update failed. Restore point: $backup_dir" + return 1 + fi + + # Verify critical tools still work + local critical_tools=(git zsh python3 brew) + for tool in "${critical_tools[@]}"; do + if ! command -v "$tool" >/dev/null; then + echo "โŒ Critical tool $tool missing after update!" + echo "๐Ÿ”„ Restore point available: $backup_dir" + return 1 + fi + done + + # Safe cleanup + brew cleanup --prune=all + brew autoremove + + # Update fzf if present + echo "๐Ÿ”„ Refreshing development tools..." + if [[ -d ~/.fzf ]]; then + (cd ~/.fzf && git pull && ./install --all) >/dev/null 2>&1 || true + fi + + # Check for broken symlinks + echo "๐Ÿงน Checking for broken symlinks..." + local broken_links=$(find "/usr/local/bin" "$HOME/bin" "$HOME/.local/bin" -xtype l 2>/dev/null) + [[ -n "$broken_links" ]] && echo "๐Ÿ”— Broken symlinks found:\n$broken_links" + + # Moon phase logging (with API key check and graceful failure) + echo "๐ŸŒ“ Celestial context:" + if [[ -n "$MOON_API_KEY" ]] && command -v curl >/dev/null && command -v jq >/dev/null; then + local moon_json=$(curl -s "https://api.ipgeolocation.io/astronomy?apiKey=$MOON_API_KEY" 2>/dev/null) + if [[ $? -eq 0 ]] && [[ -n "$moon_json" ]]; then + local moon_phase=$(echo "$moon_json" | jq -r '.moon_phase // "Unknown"') + local illum=$(echo "$moon_json" | jq -r '.moon_illumination_percentage // "Unknown"') + echo "๐ŸŒ™ $moon_phase (${illum}%)" + else + echo "๐ŸŒ™ Moon phase unavailable" + fi + else + echo "๐ŸŒ™ Moon phase tracking disabled (missing API key or tools)" + fi + + # Dotfiles management (corrected path) + if [[ -d "$DOTFILES_PATH" ]]; then + echo "๐Ÿ“ Syncing dotfiles..." + ( + cd "$DOTFILES_PATH" || return + git add . + git commit -m "๐Ÿ”ง Auto-commit from sysupdate on $(date '+%Y-%m-%d %H:%M')" 2>/dev/null || true + git push 2>/dev/null || true + brew bundle dump --force --file="$DOTFILES_PATH/Brewfile" 2>/dev/null || true + ) + fi + + # System information summary + echo "๐Ÿ“Š System Status:" + echo "๐Ÿ’ป $(uname -a)" + echo "๐Ÿ“… macOS: $(sw_vers -productVersion)" + echo "๐Ÿง  Memory: $(top -l 1 -s 0 | grep PhysMem | awk '{print $2 " used, " $6 " available"}')" + echo "๐Ÿ’ฟ Disk: $(df -h / | tail -1 | awk '{print $3 " used, " $4 " available (" $5 " full)"}')" + + # Post-update hooks + if [[ -x "$HOME/.zsh/hooks/post-update" ]]; then + echo "๐Ÿช Running post-update hooks..." + "$HOME/.zsh/hooks/post-update" + fi + + local duration=$(($(date +%s) - start_time)) + echo "๐Ÿ•“ Update completed in ${duration}s" + + # Success notification + if command -v osascript >/dev/null; then + osascript -e 'display notification "All systems updated successfully! ๐Ÿš€" with title "System Maintenance Complete"' + fi + + # Cleanup old snapshots (keep last 5) + find "$HOME/.system-snapshots" -maxdepth 1 -type d -name "20*" | sort -r | tail -n +6 | xargs rm -rf 2>/dev/null || true +} + +# Quiet version for automated updates +quietupdate() { + sysupdate >/dev/null 2>&1 + echo "Silent update completed at $(date)" +} + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# II. COMPREHENSIVE SYSTEM CLEANING +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +deep_clean() { + echo "๐Ÿงน Initiating deep system cleaning..." + local cleaned=() + + # DS_Store cleanup + local ds_count=$(find "$HOME" -name ".DS_Store" -delete -print 2>/dev/null | wc -l) + [[ $ds_count -gt 0 ]] && cleaned+=("$ds_count .DS_Store files") + + # Broken symlinks + local broken_symlinks=$(find "$HOME/bin" "$HOME/.local/bin" -xtype l 2>/dev/null) + if [[ -n "$broken_symlinks" ]]; then + echo "$broken_symlinks" | xargs rm -f + local broken_count=$(echo "$broken_symlinks" | wc -l) + cleaned+=("$broken_count broken symlinks") + fi + + # Cache cleanup + local cache_dirs=( + "$HOME/Library/Caches/pip" + "$HOME/.npm/_cacache" + "$HOME/.cache" + "$HOME/Library/Caches/Homebrew" + ) + + for cache_dir in "${cache_dirs[@]}"; do + if [[ -d "$cache_dir" ]]; then + local cache_size=$(du -sh "$cache_dir" 2>/dev/null | cut -f1) + rm -rf "$cache_dir"/* 2>/dev/null || true + [[ -n "$cache_size" ]] && cleaned+=("$cache_size from $(basename "$cache_dir") cache") + fi + done + + # Homebrew cleanup + if command -v brew >/dev/null; then + local brew_output=$(brew cleanup --prune=all 2>&1) + [[ "$brew_output" != *"Nothing to do"* ]] && cleaned+=("Homebrew packages") + fi + + # Launch Services cleanup + echo "๐Ÿ”„ Rebuilding Launch Services database..." + /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user 2>/dev/null || true + cleaned+=("Launch Services database") + + # Trash cleanup (with confirmation) + if [[ -n "$(ls -A ~/.Trash 2>/dev/null)" ]]; then + echo -n "๐Ÿ—‘๏ธ Empty Trash? (y/N): " + read -r response + if [[ "$response" =~ ^[Yy]$ ]]; then + rm -rf ~/.Trash/* 2>/dev/null || true + cleaned+=("Trash contents") + fi + fi + + # Summary + if [[ ${#cleaned[@]} -gt 0 ]]; then + echo "โœ… Cleaned: ${(j:, :)cleaned}" + else + echo "โœจ System already clean!" + fi + + # Final system state + echo "๐Ÿ’ฟ Free space: $(df -h / | tail -1 | awk '{print $4}')" +} + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# III. VAULT & OBSIDIAN INTEGRATION +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Create or open today's daily note +today() { + if [[ ! -d "$VAULT_PATH" ]]; then + echo "โŒ Vault not found at: $VAULT_PATH" + return 1 + fi + + local daily_path="$VAULT_PATH/01. Daily" + local today_file="$daily_path/$(date +%Y-%m-%d).md" + local template_file="$VAULT_PATH/98. Templates/Daily Note Template.md" + + # Create daily note from template if it doesn't exist + if [[ ! -f "$today_file" ]]; then + if [[ -f "$template_file" ]]; then + cp "$template_file" "$today_file" + echo "๐Ÿ“ Created today's daily note" + else + echo "โš ๏ธ Template not found, creating basic daily note" + echo "# $(date +%Y-%m-%d)\n\n## Morning\n\n## Evening\n\n" > "$today_file" + fi + fi + + # Open in Obsidian + if command -v open >/dev/null; then + open -a Obsidian "$today_file" + else + echo "๐Ÿ“ Daily note: $today_file" + fi +} + +# Quick vault search with fzf +vf() { + if [[ ! -d "$VAULT_PATH" ]]; then + echo "โŒ Vault not found" + return 1 + fi + + if ! command -v fzf >/dev/null; then + echo "โŒ fzf not available" + return 1 + fi + + local file + file=$(find "$VAULT_PATH" -name "*.md" -not -path "*/.*" | \ + sed "s|$VAULT_PATH/||" | \ + fzf --preview "head -20 '$VAULT_PATH/{}'" \ + --preview-window=right:60% \ + --header="Select vault file to open") + + if [[ -n "$file" ]]; then + open -a Obsidian "$VAULT_PATH/$file" + fi +} + +# Weekly review creation +weekly() { + local week_num=$(date +%U) + local year=$(date +%Y) + local weekly_file="$VAULT_PATH/02. Reviews & Planning/${year}-W${week_num}.md" + local template_file="$VAULT_PATH/98. Templates/Weekly_Review_Template.md" + + if [[ ! -f "$weekly_file" ]] && [[ -f "$template_file" ]]; then + cp "$template_file" "$weekly_file" + echo "๐Ÿ“… Created weekly review for week $week_num" + fi + + open -a Obsidian "$weekly_file" 2>/dev/null || echo "๐Ÿ“ Weekly review: $weekly_file" +} + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# IV. CHAMBER & WORKFLOW INTEGRATION +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Chamber mode switching +chamber() { + local mode="${1:-unified}" + local mode_file="$CHAMBER_PATH/docs/chamber/workflow/MODE-${mode^^}.md" + + if [[ -f "$mode_file" ]]; then + open "$mode_file" 2>/dev/null || echo "๐Ÿ“ Chamber mode: $mode_file" + cd "$CHAMBER_PATH" 2>/dev/null || true + export CURRENT_CONTEXT="chamber" + else + echo "โŒ Chamber mode '$mode' not found" + echo "Available modes:" + ls "$CHAMBER_PATH/docs/chamber/workflow/MODE-"*.md 2>/dev/null | \ + sed 's/.*MODE-\(.*\)\.md/\1/' | tr '[:upper:]' '[:lower:]' || echo "None found" + fi +} + +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• +# V. UTILITY FUNCTIONS +# โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• + +# Enhanced weather function +wttr() { + local location=${1:-} + local format=${2:-"?n"} # Default to narrow format + + if command -v curl >/dev/null; then + curl -s "wttr.in/${location}${format}" + else + echo "โŒ curl not available for weather lookup" + fi +} + +# PDF compression with quality options +pdfcompress() { + local input_file="$1" + local quality="${2:-screen}" # screen, ebook, printer, prepress + + if [[ ! -f "$input_file" ]]; then + echo "โŒ File not found: $input_file" + return 1 + fi + + if ! command -v gs >/dev/null; then + echo "โŒ Ghostscript not found. Install with: brew install ghostscript" + return 1 + fi + + local output_file="${input_file%.*}.compressed.pdf" + + gs -q -dNOPAUSE -dBATCH -dSAFER \ + -sDEVICE=pdfwrite \ + -dCompatibilityLevel=1.4 \ + -dPDFSETTINGS=/"$quality" \ + -dEmbedAllFonts=true \ + -dSubsetFonts=true \ + -sOutputFile="$output_file" \ + "$input_file" + + if [[ -f "$output_file" ]]; then + local original_size=$(du -h "$input_file" | cut -f1) + local compressed_size=$(du -h "$output_file" | cut -f1) + echo "โœ… Compressed: $original_size โ†’ $compressed_size" + echo "๐Ÿ“ Output: $output_file" + else + echo "โŒ Compression failed" + return 1 + fi +} + +# Context-aware directory change with hooks +smart_cd() { + cd "$@" && detect_context + + # Auto-activate virtual environments + if [[ -f "venv/bin/activate" ]]; then + echo "๐Ÿ Virtual environment detected" + fi + + # Show git status in git repos + if [[ -d ".git" ]] && command -v git >/dev/null; then + echo "๐Ÿ“Š $(git branch --show-current) | $(git status --porcelain | wc -l | tr -d ' ') changes" + fi +} + +# Override cd with smart_cd +alias cd='smart_cd' + +# Add context detection to prompt changes +chpwd_functions+=(detect_context) \ No newline at end of file diff --git a/shell/paths.zsh b/shell/paths.zsh new file mode 100644 index 0000000..cf0bd09 --- /dev/null +++ b/shell/paths.zsh @@ -0,0 +1,82 @@ +# โ–‘โ–ˆโ–€โ–ˆโ–‘โ–ˆโ–€โ–ˆโ–‘โ–€โ–ˆโ–€โ–‘โ–ˆโ–‘โ–ˆโ–‘โ–ˆโ–€โ–€ +# โ–‘โ–ˆโ–€โ–€โ–‘โ–ˆโ–€โ–ˆโ–‘โ–‘โ–ˆโ–‘โ–‘โ–ˆโ–€โ–ˆโ–‘โ–€โ–€โ–ˆ +# โ–‘โ–€โ–‘โ–‘โ–‘โ–€โ–‘โ–€โ–‘โ–‘โ–€โ–‘โ–‘โ–€โ–‘โ–€โ–‘โ–€โ–€โ–€ + +# 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 \ No newline at end of file