Refactor shell configuration following prime directive principles
🎯 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>
This commit is contained in:
co-authored by
Claude
parent
6ce6e7c042
commit
546e43fc64
+6
-12
@@ -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}"
|
||||
|
||||
Executable
+126
@@ -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"
|
||||
Reference in New Issue
Block a user