chore: Updated install script d548ed20
Steve Simkins · 2025-06-25 16:08 1 file(s) · +454 −110
install.sh +454 −110
1 1
#!/bin/bash
2 2
3 -
# Darkmatter Terminal Setup - Opinionated terminal configuration installer
3 +
# Darkmatter Terminal Setup - Remote configuration installer
4 +
# Downloads and installs terminal configuration from GitHub
4 5
# Requires: Homebrew (https://brew.sh)
5 6
6 -
set -e  # Exit on any error
7 +
set -euo pipefail  # Exit on any error, undefined variables, and pipe failures
8 +
9 +
# Configuration - Update these URLs to match your GitHub repo
10 +
GITHUB_RAW_BASE="https://raw.githubusercontent.com/stevedylandev/darkmatter/main"
11 +
TEMP_DIR="/tmp/darkmatter_install"
12 +
DEBUG_MODE="${DEBUG:-false}"
7 13
8 14
# Colors for output
9 15
RED='\033[0;31m'
10 16
GREEN='\033[0;32m'
11 17
YELLOW='\033[1;33m'
12 18
BLUE='\033[0;34m'
19 +
PURPLE='\033[0;35m'
13 20
NC='\033[0m' # No Color
14 21
15 22
# Function to print colored output
29 36
    echo -e "${RED}[ERROR]${NC} $1"
30 37
}
31 38
32 -
# Check if Homebrew is installed
33 -
check_homebrew() {
39 +
print_debug() {
40 +
    if [ "$DEBUG_MODE" = "true" ]; then
41 +
        echo -e "${PURPLE}[DEBUG]${NC} $1"
42 +
    fi
43 +
}
44 +
45 +
# Enhanced error handler
46 +
error_handler() {
47 +
    local line_number="$1"
48 +
    local error_code="$2"
49 +
    local command="$BASH_COMMAND"
50 +
51 +
    print_error "Script failed at line $line_number with exit code $error_code"
52 +
    print_error "Failed command: $command"
53 +
    print_error "Current function: ${FUNCNAME[1]:-main}"
54 +
55 +
    # Show some context
56 +
    if [ -f "$0" ]; then
57 +
        print_error "Context around line $line_number:"
58 +
        sed -n "$((line_number-2)),$((line_number+2))p" "$0" | nl -ba
59 +
    fi
60 +
61 +
    cleanup
62 +
    exit $error_code
63 +
}
64 +
65 +
# Set up error trap
66 +
trap 'error_handler ${LINENO} $?' ERR
67 +
68 +
# Check if required tools are available
69 +
check_dependencies() {
70 +
    print_status "Checking dependencies..."
71 +
    print_debug "Checking for brew command..."
72 +
34 73
    if ! command -v brew &> /dev/null; then
35 74
        print_error "Homebrew is not installed. Please install it first:"
36 75
        print_error "https://brew.sh"
37 76
        exit 1
38 77
    fi
39 -
    print_success "Homebrew found"
78 +
    print_success "Homebrew found at: $(which brew)"
79 +
80 +
    print_debug "Checking for curl command..."
81 +
    if ! command -v curl &> /dev/null; then
82 +
        print_error "curl is not installed. Please install it first."
83 +
        exit 1
84 +
    fi
85 +
    print_success "curl found at: $(which curl)"
86 +
87 +
    print_debug "Checking curl version..."
88 +
    curl --version | head -1
89 +
}
90 +
91 +
# Create temporary directory for downloads
92 +
setup_temp_dir() {
93 +
    print_status "Setting up temporary directory..."
94 +
    print_debug "Removing existing temp dir: $TEMP_DIR"
95 +
96 +
    if [ -d "$TEMP_DIR" ]; then
97 +
        rm -rf "$TEMP_DIR" || {
98 +
            print_error "Failed to remove existing temp directory: $TEMP_DIR"
99 +
            exit 1
100 +
        }
101 +
    fi
102 +
103 +
    print_debug "Creating temp dir: $TEMP_DIR"
104 +
    mkdir -p "$TEMP_DIR" || {
105 +
        print_error "Failed to create temporary directory: $TEMP_DIR"
106 +
        exit 1
107 +
    }
108 +
109 +
    print_success "Temporary directory created: $TEMP_DIR"
110 +
    print_debug "Temp directory permissions: $(ls -ld "$TEMP_DIR")"
40 111
}
41 112
42 -
# Install packages via Homebrew
113 +
# Test GitHub connectivity
114 +
test_github_connection() {
115 +
    print_status "Testing GitHub connectivity..."
116 +
    print_debug "Testing connection to: $GITHUB_RAW_BASE"
117 +
118 +
    # Test with a simple HEAD request
119 +
    if curl -I -f -s --connect-timeout 10 --max-time 30 "$GITHUB_RAW_BASE/.zshrc" > /dev/null; then
120 +
        print_success "Successfully connected to GitHub repository"
121 +
    else
122 +
        local exit_code=$?
123 +
        print_error "Failed to connect to GitHub repository"
124 +
        print_error "URL tested: $GITHUB_RAW_BASE/.zshrc"
125 +
        print_error "curl exit code: $exit_code"
126 +
127 +
        # Try to give more specific error information
128 +
        case $exit_code in
129 +
            6) print_error "Could not resolve host - check your internet connection" ;;
130 +
            7) print_error "Failed to connect to host - check the repository URL" ;;
131 +
            22) print_error "HTTP error - the file might not exist or repository might be private" ;;
132 +
            28) print_error "Timeout - check your internet connection" ;;
133 +
            *) print_error "Unknown curl error - check the repository URL and your internet connection" ;;
134 +
        esac
135 +
136 +
        exit 1
137 +
    fi
138 +
}
139 +
140 +
# Download file from GitHub with detailed error reporting
141 +
download_file() {
142 +
    local filename="$1"
143 +
    local url="$GITHUB_RAW_BASE/$filename"
144 +
    local dest="$TEMP_DIR/$filename"
145 +
146 +
    print_status "Downloading $filename..."
147 +
    print_debug "From: $url"
148 +
    print_debug "To: $dest"
149 +
150 +
    # Create directory if needed
151 +
    local dest_dir=$(dirname "$dest")
152 +
    if [ ! -d "$dest_dir" ]; then
153 +
        mkdir -p "$dest_dir" || {
154 +
            print_error "Failed to create directory: $dest_dir"
155 +
            return 1
156 +
        }
157 +
    fi
158 +
159 +
    # Download with verbose error reporting
160 +
    local curl_output
161 +
    curl_output=$(curl -L -f -s -w "HTTP_CODE:%{http_code};SIZE:%{size_download};TIME:%{time_total}" -o "$dest" "$url" 2>&1) || {
162 +
        local exit_code=$?
163 +
        print_error "Failed to download $filename"
164 +
        print_error "URL: $url"
165 +
        print_error "curl exit code: $exit_code"
166 +
        print_error "curl output: $curl_output"
167 +
        return 1
168 +
    }
169 +
170 +
    print_debug "curl response: $curl_output"
171 +
172 +
    # Verify file was downloaded and has content
173 +
    if [ ! -f "$dest" ]; then
174 +
        print_error "File was not created: $dest"
175 +
        return 1
176 +
    fi
177 +
178 +
    local file_size=$(wc -c < "$dest" 2>/dev/null || echo "0")
179 +
    if [ "$file_size" -eq 0 ]; then
180 +
        print_error "Downloaded file is empty: $filename"
181 +
        return 1
182 +
    fi
183 +
184 +
    print_success "Downloaded $filename (${file_size} bytes)"
185 +
    print_debug "File content preview:"
186 +
    if [ "$DEBUG_MODE" = "true" ]; then
187 +
        head -3 "$dest" || true
188 +
    fi
189 +
190 +
    return 0
191 +
}
192 +
193 +
# Download all configuration files
194 +
download_configs() {
195 +
    print_status "Downloading configuration files from GitHub..."
196 +
197 +
    local files=(
198 +
        ".zshrc"
199 +
        "config"
200 +
        "starship.toml"
201 +
    )
202 +
203 +
    local success_count=0
204 +
    local total_files=${#files[@]}
205 +
206 +
    print_debug "Starting download loop for ${total_files} files"
207 +
208 +
    for file in "${files[@]}"; do
209 +
        print_debug "=== Processing file $((success_count + 1))/$total_files: $file ==="
210 +
        print_status "Attempting to download: $file"
211 +
212 +
        # Disable error exit temporarily for this specific operation
213 +
        set +e
214 +
        download_file "$file"
215 +
        local download_result=$?
216 +
        set -e
217 +
218 +
        print_debug "Download result for $file: $download_result"
219 +
220 +
        if [ $download_result -eq 0 ]; then
221 +
            success_count=$((success_count + 1))
222 +
            print_success "Successfully downloaded: $file (count: $success_count)"
223 +
        else
224 +
            print_error "Failed to download $file (exit code: $download_result)"
225 +
            print_error "This will cause installation issues"
226 +
            # Continue with other files to see what we can get
227 +
        fi
228 +
229 +
        print_debug "Completed processing $file, moving to next file"
230 +
    done
231 +
232 +
    print_debug "Download loop completed"
233 +
    print_status "Downloaded $success_count/$total_files configuration files"
234 +
235 +
    if [ $success_count -eq $total_files ]; then
236 +
        print_success "All configuration files downloaded successfully"
237 +
    else
238 +
        print_error "Failed to download some configuration files ($success_count/$total_files succeeded)"
239 +
        print_error "Installation cannot continue without all config files"
240 +
241 +
        # Show what files we do have
242 +
        print_status "Files in temp directory:"
243 +
        ls -la "$TEMP_DIR" || true
244 +
245 +
        exit 1
246 +
    fi
247 +
}
248 +
249 +
# Download and install font
250 +
download_and_install_font() {
251 +
    print_status "Downloading CommitMono Nerd Font..."
252 +
253 +
    local font_filename="CommitMonoNerdFont-Regular.otf"
254 +
    local font_url="$GITHUB_RAW_BASE/assets/$font_filename"
255 +
    local font_dest="$TEMP_DIR/$font_filename"
256 +
257 +
    print_debug "Font download URL: $font_url"
258 +
259 +
    # Create assets subdirectory in temp
260 +
    mkdir -p "$TEMP_DIR/assets"
261 +
    font_dest="$TEMP_DIR/assets/$font_filename"
262 +
263 +
    if curl -L -f -s -w "HTTP_CODE:%{http_code};SIZE:%{size_download}" -o "$font_dest" "$font_url" 2>/dev/null; then
264 +
        local file_size=$(wc -c < "$font_dest" 2>/dev/null || echo "0")
265 +
        print_success "Downloaded CommitMono Nerd Font (${file_size} bytes)"
266 +
267 +
        # Verify it's actually a font file (should be reasonably large)
268 +
        if [ "$file_size" -lt 10000 ]; then
269 +
            print_warning "Font file seems too small, might be an error page"
270 +
            print_debug "Font file content preview:"
271 +
            if [ "$DEBUG_MODE" = "true" ]; then
272 +
                head -3 "$font_dest" || true
273 +
            fi
274 +
        fi
275 +
    else
276 +
        print_warning "Failed to download font from $font_url"
277 +
        print_warning "Continuing without font installation..."
278 +
        return 1
279 +
    fi
280 +
281 +
    # Install the font
282 +
    print_status "Installing CommitMono Nerd Font..."
283 +
284 +
    local user_fonts_dir="$HOME/Library/Fonts"
285 +
    print_debug "Font installation directory: $user_fonts_dir"
286 +
287 +
    if [ ! -d "$user_fonts_dir" ]; then
288 +
        mkdir -p "$user_fonts_dir" || {
289 +
            print_error "Failed to create fonts directory: $user_fonts_dir"
290 +
            return 1
291 +
        }
292 +
    fi
293 +
294 +
    local dest_file="$user_fonts_dir/$font_filename"
295 +
296 +
    if [ -f "$dest_file" ]; then
297 +
        print_warning "Font $font_filename already installed, skipping"
298 +
    else
299 +
        cp "$font_dest" "$dest_file" || {
300 +
            print_error "Failed to copy font to $dest_file"
301 +
            return 1
302 +
        }
303 +
        print_success "Installed font: $font_filename"
304 +
305 +
        # Clear font cache on macOS
306 +
        print_status "Refreshing font cache..."
307 +
        if command -v atsutil &> /dev/null; then
308 +
            sudo atsutil databases -remove 2>/dev/null || print_debug "atsutil databases -remove failed"
309 +
            atsutil server -shutdown 2>/dev/null || print_debug "atsutil server -shutdown failed"
310 +
            atsutil server -ping 2>/dev/null || print_debug "atsutil server -ping failed"
311 +
        else
312 +
            print_debug "atsutil not found, skipping font cache refresh"
313 +
        fi
314 +
315 +
        print_success "Font installation complete!"
316 +
        print_status "You may need to restart applications to see the new font"
317 +
    fi
318 +
}
319 +
320 +
# Install packages via Homebrew with better error handling
43 321
install_packages() {
44 322
    print_status "Installing packages via Homebrew..."
45 323
56 334
        "ghostty"
57 335
    )
58 336
337 +
    # Update Homebrew first
338 +
    print_status "Updating Homebrew..."
339 +
    brew update || print_warning "Homebrew update failed, continuing anyway..."
340 +
59 341
    # Install regular packages
60 342
    for package in "${packages[@]}"; do
61 343
        print_status "Installing $package..."
344 +
        print_debug "Checking if $package is already installed..."
345 +
62 346
        if brew list "$package" &>/dev/null; then
63 347
            print_warning "$package is already installed"
64 348
        else
65 -
            brew install "$package"
66 -
            print_success "Installed $package"
349 +
            print_debug "Installing $package with brew..."
350 +
            if brew install "$package"; then
351 +
                print_success "Installed $package"
352 +
            else
353 +
                print_error "Failed to install $package"
354 +
                # Don't exit, try to continue with other packages
355 +
            fi
67 356
        fi
68 357
    done
69 358
70 359
    # Install cask packages
71 360
    for package in "${cask_packages[@]}"; do
72 361
        print_status "Installing $package (cask)..."
362 +
        print_debug "Checking if cask $package is already installed..."
363 +
73 364
        if brew list --cask "$package" &>/dev/null; then
74 365
            print_warning "$package is already installed"
75 366
        else
76 -
            brew install --cask "$package"
77 -
            print_success "Installed $package"
367 +
            print_debug "Installing cask $package with brew..."
368 +
            if brew install --cask "$package"; then
369 +
                print_success "Installed $package"
370 +
            else
371 +
                print_warning "Failed to install $package (cask) - this might not be critical"
372 +
                # Ghostty might not be available, but don't fail the whole script
373 +
            fi
78 374
        fi
79 375
    done
80 376
}
86 382
    local timestamp=$(date +%Y%m%d_%H%M%S)
87 383
    local backup_dir="$HOME/.config_backup_$timestamp"
88 384
89 -
    mkdir -p "$backup_dir"
385 +
    print_debug "Backup directory: $backup_dir"
386 +
387 +
    mkdir -p "$backup_dir" || {
388 +
        print_error "Failed to create backup directory: $backup_dir"
389 +
        exit 1
390 +
    }
391 +
392 +
    local backed_up=false
90 393
91 394
    if [ -f "$HOME/.zshrc" ]; then
92 -
        cp "$HOME/.zshrc" "$backup_dir/"
93 -
        print_success "Backed up .zshrc to $backup_dir"
395 +
        cp "$HOME/.zshrc" "$backup_dir/" && {
396 +
            print_success "Backed up .zshrc to $backup_dir"
397 +
            backed_up=true
398 +
        } || print_warning "Failed to backup .zshrc"
94 399
    fi
95 400
96 401
    if [ -f "$HOME/.config/ghostty/config" ]; then
97 -
        cp "$HOME/.config/ghostty/config" "$backup_dir/"
98 -
        print_success "Backed up ghotty config to $backup_dir"
402 +
        mkdir -p "$backup_dir/.config/ghostty"
403 +
        cp "$HOME/.config/ghostty/config" "$backup_dir/.config/ghostty/" && {
404 +
            print_success "Backed up ghostty config to $backup_dir"
405 +
            backed_up=true
406 +
        } || print_warning "Failed to backup ghostty config"
99 407
    fi
100 408
101 409
    if [ -f "$HOME/.config/starship.toml" ]; then
102 410
        mkdir -p "$backup_dir/.config"
103 -
        cp "$HOME/.config/starship.toml" "$backup_dir/.config/"
104 -
        print_success "Backed up starship.toml to $backup_dir"
411 +
        cp "$HOME/.config/starship.toml" "$backup_dir/.config/" && {
412 +
            print_success "Backed up starship.toml to $backup_dir"
413 +
            backed_up=true
414 +
        } || print_warning "Failed to backup starship.toml"
105 415
    fi
106 -
}
107 416
108 -
# Install fonts from assets directory
109 -
install_fonts() {
110 -
    print_status "Installing CommitMono Nerd Font..."
111 -
112 -
    local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
113 -
    local assets_dir="$script_dir/assets"
114 -
115 -
    if [ ! -d "$assets_dir" ]; then
116 -
        print_warning "Assets directory not found, skipping font installation"
117 -
        return
118 -
    fi
119 -
120 -
    # Create user fonts directory
121 -
    local user_fonts_dir="$HOME/Library/Fonts"
122 -
    mkdir -p "$user_fonts_dir"
123 -
124 -
    # Count fonts to install
125 -
    local font_count=0
126 -
    for font_file in "$assets_dir"/*.{otf,ttf,OTF,TTF}; do
127 -
        [ -f "$font_file" ] && ((font_count++))
128 -
    done
129 -
130 -
    if [ $font_count -eq 0 ]; then
131 -
        print_warning "No font files found in assets directory"
132 -
        return
133 -
    fi
134 -
135 -
    print_status "Found $font_count CommitMono font files to install"
136 -
137 -
    # Install fonts
138 -
    local installed_count=0
139 -
    for font_file in "$assets_dir"/*.{otf,ttf,OTF,TTF}; do
140 -
        if [ -f "$font_file" ]; then
141 -
            local font_name=$(basename "$font_file")
142 -
            local dest_file="$user_fonts_dir/$font_name"
143 -
144 -
            # Check if font already exists
145 -
            if [ -f "$dest_file" ]; then
146 -
                print_warning "Font $font_name already installed, skipping"
147 -
            else
148 -
                cp "$font_file" "$dest_file"
149 -
                print_success "Installed font: $font_name"
150 -
                ((installed_count++))
151 -
            fi
152 -
        fi
153 -
    done
154 -
155 -
    if [ $installed_count -gt 0 ]; then
156 -
        # Clear font cache on macOS
157 -
        print_status "Refreshing font cache..."
158 -
159 -
        # Clear system font cache
160 -
        sudo atsutil databases -remove 2>/dev/null || true
161 -
        atsutil server -shutdown 2>/dev/null || true
162 -
        atsutil server -ping 2>/dev/null || true
163 -
164 -
        print_success "Installed $installed_count new fonts!"
165 -
        print_status "You may need to restart applications to see the new fonts"
166 -
    else
167 -
        print_success "All CommitMono fonts are already installed"
417 +
    if [ "$backed_up" = false ]; then
418 +
        print_status "No existing configuration files to backup"
419 +
        rmdir "$backup_dir" 2>/dev/null || true
168 420
    fi
169 421
}
170 422
171 -
# Copy configuration files from the repo
172 -
copy_configs() {
173 -
    print_status "Copying configuration files..."
423 +
# Copy downloaded configuration files to their destinations
424 +
install_configs() {
425 +
    print_status "Installing configuration files..."
174 426
175 -
    local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
427 +
    local install_errors=0
176 428
177 -
    # Copy .zshrc
178 -
    if [ -f "$script_dir/.zshrc" ]; then
179 -
        cp "$script_dir/.zshrc" "$HOME/"
180 -
        print_success "Copied .zshrc"
429 +
    # Install .zshrc
430 +
    if [ -f "$TEMP_DIR/.zshrc" ]; then
431 +
        print_debug "Installing .zshrc to $HOME/"
432 +
        if cp "$TEMP_DIR/.zshrc" "$HOME/"; then
433 +
            print_success "Installed .zshrc"
434 +
        else
435 +
            print_error "Failed to install .zshrc"
436 +
            ((install_errors++))
437 +
        fi
181 438
    else
182 -
        print_warning ".zshrc not found in repo"
439 +
        print_error ".zshrc not found in downloaded files: $TEMP_DIR/.zshrc"
440 +
        ((install_errors++))
183 441
    fi
184 442
185 -
    # Copy ghostty config
186 -
    if [ -f "$script_dir/config" ]; then
443 +
    # Install ghostty config
444 +
    if [ -f "$TEMP_DIR/config" ]; then
445 +
        print_debug "Installing ghostty config to $HOME/.config/ghostty/"
187 446
        mkdir -p "$HOME/.config/ghostty"
188 -
        cp "$script_dir/config" "$HOME/.config/ghostty/"
189 -
        print_success "Copied Ghostty config"
447 +
        if cp "$TEMP_DIR/config" "$HOME/.config/ghostty/"; then
448 +
            print_success "Installed Ghostty config"
449 +
        else
450 +
            print_error "Failed to install Ghostty config"
451 +
            ((install_errors++))
452 +
        fi
190 453
    else
191 -
        print_warning "Ghostty config not found in repo"
454 +
        print_error "Ghostty config not found in downloaded files: $TEMP_DIR/config"
455 +
        ((install_errors++))
192 456
    fi
193 457
194 -
    # Copy starship config
195 -
    if [ -f "$script_dir/starship.toml" ]; then
458 +
    # Install starship config
459 +
    if [ -f "$TEMP_DIR/starship.toml" ]; then
460 +
        print_debug "Installing starship config to $HOME/.config/"
196 461
        mkdir -p "$HOME/.config"
197 -
        cp "$script_dir/starship.toml" "$HOME/.config/"
198 -
        print_success "Copied starship.toml"
462 +
        if cp "$TEMP_DIR/starship.toml" "$HOME/.config/"; then
463 +
            print_success "Installed starship.toml"
464 +
        else
465 +
            print_error "Failed to install starship.toml"
466 +
            ((install_errors++))
467 +
        fi
199 468
    else
200 -
        print_warning "starship.toml not found in repo"
469 +
        print_error "starship.toml not found in downloaded files: $TEMP_DIR/starship.toml"
470 +
        ((install_errors++))
471 +
    fi
472 +
473 +
    if [ $install_errors -gt 0 ]; then
474 +
        print_error "$install_errors configuration files failed to install"
475 +
        exit 1
201 476
    fi
202 477
}
203 478
204 479
# Set zsh as default shell
205 480
set_default_shell() {
206 -
    local current_shell=$(echo $SHELL)
207 -
    local zsh_path=$(which zsh)
481 +
    print_status "Checking default shell..."
482 +
483 +
    local current_shell="${SHELL}"
484 +
    local zsh_path
485 +
    zsh_path=$(which zsh) || {
486 +
        print_error "zsh not found in PATH"
487 +
        exit 1
488 +
    }
489 +
490 +
    print_debug "Current shell: $current_shell"
491 +
    print_debug "zsh path: $zsh_path"
208 492
209 493
    if [ "$current_shell" != "$zsh_path" ]; then
210 494
        print_status "Setting zsh as default shell..."
211 495
212 496
        # Add zsh to /etc/shells if not present
213 -
        if ! grep -q "$zsh_path" /etc/shells; then
214 -
            echo "$zsh_path" | sudo tee -a /etc/shells
497 +
        if ! grep -q "$zsh_path" /etc/shells 2>/dev/null; then
498 +
            print_debug "Adding $zsh_path to /etc/shells"
499 +
            echo "$zsh_path" | sudo tee -a /etc/shells > /dev/null || {
500 +
                print_error "Failed to add zsh to /etc/shells"
501 +
                exit 1
502 +
            }
215 503
        fi
216 504
217 505
        # Change default shell
218 -
        chsh -s "$zsh_path"
219 -
        print_success "Default shell set to zsh"
220 -
        print_warning "Please restart your terminal or run 'exec zsh' to use the new shell"
506 +
        print_debug "Changing default shell to $zsh_path"
507 +
        if chsh -s "$zsh_path"; then
508 +
            print_success "Default shell set to zsh"
509 +
            print_warning "Please restart your terminal or run 'exec zsh' to use the new shell"
510 +
        else
511 +
            print_error "Failed to change default shell"
512 +
            exit 1
513 +
        fi
221 514
    else
222 515
        print_success "zsh is already the default shell"
223 516
    fi
224 517
}
225 518
519 +
# Cleanup temporary files
520 +
cleanup() {
521 +
    if [ -d "$TEMP_DIR" ]; then
522 +
        print_debug "Cleaning up temporary files from: $TEMP_DIR"
523 +
        rm -rf "$TEMP_DIR" || print_warning "Failed to clean up temporary directory"
524 +
        print_success "Cleanup complete"
525 +
    fi
526 +
}
527 +
528 +
# Show debug information
529 +
show_debug_info() {
530 +
    if [ "$DEBUG_MODE" = "true" ]; then
531 +
        print_debug "=== Debug Information ==="
532 +
        print_debug "Script: $0"
533 +
        print_debug "Working directory: $(pwd)"
534 +
        print_debug "User: $USER"
535 +
        print_debug "Home: $HOME"
536 +
        print_debug "Shell: $SHELL"
537 +
        print_debug "PATH: $PATH"
538 +
        print_debug "GitHub base URL: $GITHUB_RAW_BASE"
539 +
        print_debug "Temp directory: $TEMP_DIR"
540 +
        print_debug "========================="
541 +
    fi
542 +
}
543 +
226 544
# Main installation function
227 545
main() {
228 -
    echo "🌑 Darkmatter Setup Installer"
229 -
    echo "=========================="
546 +
    echo "🌑 Darkmatter Setup Installer (Remote)"
547 +
    echo "======================================"
230 548
    echo
231 549
232 -
    check_homebrew
550 +
    # Enable debug mode if requested
551 +
    if [ "${1:-}" = "--debug" ] || [ "${1:-}" = "-d" ]; then
552 +
        DEBUG_MODE="true"
553 +
        print_status "Debug mode enabled"
554 +
    fi
555 +
556 +
    show_debug_info
557 +
558 +
    # Check if GITHUB_RAW_BASE needs to be updated
559 +
    if [[ "$GITHUB_RAW_BASE" == *"your-username/your-repo"* ]]; then
560 +
        print_error "Please update the GITHUB_RAW_BASE variable in this script"
561 +
        print_error "Set it to your actual GitHub repository URL"
562 +
        print_error "Example: https://raw.githubusercontent.com/username/repo-name/main"
563 +
        exit 1
564 +
    fi
565 +
566 +
    print_status "Starting installation process..."
567 +
568 +
    check_dependencies
569 +
    setup_temp_dir
570 +
    test_github_connection
571 +
    download_configs
572 +
    download_and_install_font
233 573
    install_packages
234 574
    backup_configs
235 -
    copy_configs
236 -
    install_fonts
575 +
    install_configs
237 576
    set_default_shell
577 +
    cleanup
238 578
239 579
    echo
240 580
    print_success "Installation complete! 🌌"
243 583
    echo "  1. Restart your terminal or run: exec zsh"
244 584
    echo "  2. Open Ghostty to use your new terminal setup"
245 585
    echo "  3. Enjoy your Darkmatter terminal experience!"
586 +
    echo
246 587
}
247 588
248 -
# Run main function
589 +
# Handle script interruption
590 +
trap cleanup EXIT
591 +
592 +
# Run main function with all arguments
249 593
main "$@"