|
| 1 | +# Hypercube Custom Commands |
| 2 | + |
| 3 | +# Reset user configs to Hypercube defaults |
| 4 | +hypercube-config-reset: |
| 5 | + #!/usr/bin/bash |
| 6 | + set -euo pipefail |
| 7 | + |
| 8 | + echo "Hypercube Config Reset" |
| 9 | + echo "======================" |
| 10 | + echo "" |
| 11 | + echo "This will:" |
| 12 | + echo " 1. Archive your existing configs to ~/.config/hypercube-backup-<timestamp>/" |
| 13 | + echo " 2. Create new config stubs that source Hypercube system defaults" |
| 14 | + echo "" |
| 15 | + echo "Configs that will be reset:" |
| 16 | + echo " - Ghostty (~/.config/ghostty/)" |
| 17 | + echo " - Wezterm (~/.config/wezterm/)" |
| 18 | + echo "" |
| 19 | + echo "You can restore your old configs from the backup directory at any time." |
| 20 | + echo "" |
| 21 | + |
| 22 | + read -p "Continue? [y/N] " -n 1 -r |
| 23 | + echo |
| 24 | + if [[ ! $REPLY =~ ^[Yy]$ ]]; then |
| 25 | + echo "Aborted." |
| 26 | + exit 0 |
| 27 | + fi |
| 28 | + |
| 29 | + # Create backup directory with timestamp |
| 30 | + BACKUP_DIR="$HOME/.config/hypercube-backup-$(date +%Y%m%d-%H%M%S)" |
| 31 | + mkdir -p "$BACKUP_DIR" |
| 32 | + echo "" |
| 33 | + echo "Created backup directory: $BACKUP_DIR" |
| 34 | + |
| 35 | + # Function to backup and reset a config |
| 36 | + backup_and_reset() { |
| 37 | + local config_path="$1" |
| 38 | + local config_name="$2" |
| 39 | + |
| 40 | + if [[ -e "$HOME/.config/$config_path" ]]; then |
| 41 | + echo " Backing up $config_name..." |
| 42 | + mkdir -p "$BACKUP_DIR/$(dirname "$config_path")" |
| 43 | + mv "$HOME/.config/$config_path" "$BACKUP_DIR/$config_path" |
| 44 | + fi |
| 45 | + } |
| 46 | + |
| 47 | + echo "" |
| 48 | + echo "Backing up existing configs..." |
| 49 | + |
| 50 | + # Backup existing configs |
| 51 | + backup_and_reset "ghostty" "Ghostty" |
| 52 | + backup_and_reset "wezterm" "Wezterm" |
| 53 | + |
| 54 | + echo "" |
| 55 | + echo "Creating Hypercube config stubs..." |
| 56 | + |
| 57 | + # Create Ghostty stub |
| 58 | + mkdir -p "$HOME/.config/ghostty" |
| 59 | + cat > "$HOME/.config/ghostty/config" << 'EOF' |
| 60 | +# Hypercube Ghostty Configuration |
| 61 | +# System defaults are sourced below. Add your customizations after this line. |
| 62 | +# To replace defaults entirely, remove or comment out the config-file line. |
| 63 | + |
| 64 | +config-file = /usr/share/hypercube/config/ghostty/config |
| 65 | + |
| 66 | +# Your customizations below: |
| 67 | +EOF |
| 68 | + echo " Created Ghostty config stub" |
| 69 | + |
| 70 | + # Create Wezterm stub |
| 71 | + mkdir -p "$HOME/.config/wezterm" |
| 72 | + cat > "$HOME/.config/wezterm/wezterm.lua" << 'EOF' |
| 73 | +-- Hypercube Wezterm Configuration |
| 74 | +-- System defaults are loaded below. Add your customizations after this line. |
| 75 | +-- To replace defaults entirely, remove the dofile line and start fresh. |
| 76 | + |
| 77 | +local config = dofile("/usr/share/hypercube/config/wezterm/wezterm.lua") |
| 78 | + |
| 79 | +-- Your customizations below: |
| 80 | +-- Example: config.font_size = 14 |
| 81 | + |
| 82 | +return config |
| 83 | +EOF |
| 84 | + echo " Created Wezterm config stub" |
| 85 | + |
| 86 | + echo "" |
| 87 | + echo "Done! Your old configs have been backed up to:" |
| 88 | + echo " $BACKUP_DIR" |
| 89 | + echo "" |
| 90 | + echo "Your new configs source Hypercube system defaults." |
| 91 | + echo "Add any customizations after the source/config-file line in each config." |
0 commit comments