🎯 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>
126 lines
2.7 KiB
Bash
Executable File
126 lines
2.7 KiB
Bash
Executable File
#!/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" |