|
1 | 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 "" |
18 | | - echo "You can restore your old configs from the backup directory at any time." |
19 | | - echo "" |
20 | | - |
21 | | - read -p "Continue? [y/N] " -n 1 -r |
22 | | - echo |
23 | | - if [[ ! $REPLY =~ ^[Yy]$ ]]; then |
24 | | - echo "Aborted." |
25 | | - exit 0 |
26 | | - fi |
27 | | - |
28 | | - # Create backup directory with timestamp |
29 | | - BACKUP_DIR="$HOME/.config/hypercube-backup-$(date +%Y%m%d-%H%M%S)" |
30 | | - mkdir -p "$BACKUP_DIR" |
31 | | - echo "" |
32 | | - echo "Created backup directory: $BACKUP_DIR" |
33 | | - |
34 | | - # Function to backup and reset a config |
35 | | - backup_and_reset() { |
36 | | - local config_path="$1" |
37 | | - local config_name="$2" |
38 | | - |
39 | | - if [[ -e "$HOME/.config/$config_path" ]]; then |
40 | | - echo " Backing up $config_name..." |
41 | | - mkdir -p "$BACKUP_DIR/$(dirname "$config_path")" |
42 | | - mv "$HOME/.config/$config_path" "$BACKUP_DIR/$config_path" |
43 | | - fi |
44 | | - } |
45 | | - |
46 | | - echo "" |
47 | | - echo "Backing up existing configs..." |
48 | | - |
49 | | - # Backup existing configs |
50 | | - backup_and_reset "ghostty" "Ghostty" |
51 | | - |
52 | | - echo "" |
53 | | - echo "Creating Hypercube config stubs..." |
54 | | - |
55 | | - # Create Ghostty stub |
56 | | - mkdir -p "$HOME/.config/ghostty" |
57 | | - cat > "$HOME/.config/ghostty/config" << 'EOF' |
58 | | -# Hypercube Ghostty Configuration |
59 | | -# System defaults are sourced below. Add your customizations after this line. |
60 | | -# To replace defaults entirely, remove or comment out the config-file line. |
61 | | - |
62 | | -config-file = /usr/share/hypercube/config/ghostty/config |
63 | | - |
64 | | -# Your customizations below: |
65 | | -EOF |
66 | | - echo " Created Ghostty config stub" |
67 | | - |
68 | | - echo "" |
69 | | - echo "Done! Your old configs have been backed up to:" |
70 | | - echo " $BACKUP_DIR" |
71 | | - echo "" |
72 | | - echo "Your new configs source Hypercube system defaults." |
73 | | - echo "Add any customizations after the source/config-file line in each config." |
0 commit comments