chore: Updated install to check for existing .zshrc (sorry Justin ๐Ÿ˜ฌ) 441041ae
stevedylandev ยท 2025-06-26 11:45 1 file(s) ยท +58 โˆ’7
install.sh +58 โˆ’7
412 412
    fi
413 413
}
414 414
415 +
check_darkmatter_in_zshrc() {
416 +
    local zshrc_file="$1"
417 +
418 +
    if [ ! -f "$zshrc_file" ]; then
419 +
        return 1  # File doesn't exist
420 +
    fi
421 +
422 +
    # Look for our marker comment
423 +
    if grep -q "# Darkmatter Terminal Configuration" "$zshrc_file" 2>/dev/null; then
424 +
        return 0  # Already present
425 +
    else
426 +
        return 1  # Not present
427 +
    fi
428 +
}
429 +
430 +
415 431
# Copy downloaded configuration files to their destinations
416 432
install_configs() {
417 433
    print_status "Installing configuration files..."
418 434
419 435
    local install_errors=0
420 436
421 -
    # Install .zshrc
437 +
    # Handle .zshrc installation
422 438
    if [ -f "$TEMP_DIR/.zshrc" ]; then
423 -
        print_debug "Installing .zshrc to $HOME/"
424 -
        if cp "$TEMP_DIR/.zshrc" "$HOME/"; then
425 -
            print_success "Installed .zshrc"
439 +
        if [ -f "$HOME/.zshrc" ]; then
440 +
            # Existing .zshrc found
441 +
            print_status "Existing .zshrc found, checking for Darkmatter configuration..."
442 +
443 +
            if check_darkmatter_in_zshrc "$HOME/.zshrc"; then
444 +
                print_warning "Darkmatter configuration already exists in .zshrc"
445 +
                print_status "Skipping .zshrc modification to avoid duplicates"
446 +
            else
447 +
                print_status "Appending Darkmatter configuration to existing .zshrc"
448 +
449 +
                # Add a separator and our config
450 +
                {
451 +
                    echo ""
452 +
                    echo "# ============================================="
453 +
                    echo "# Darkmatter Terminal Configuration"
454 +
                    echo "# Added by Darkmatter installer on $(date)"
455 +
                    echo "# ============================================="
456 +
                    echo ""
457 +
                    cat "$TEMP_DIR/.zshrc"
458 +
                } >> "$HOME/.zshrc" && {
459 +
                    print_success "Successfully appended Darkmatter configuration to .zshrc"
460 +
                } || {
461 +
                    print_error "Failed to append to existing .zshrc"
462 +
                    ((install_errors++))
463 +
                }
464 +
            fi
426 465
        else
427 -
            print_error "Failed to install .zshrc"
428 -
            ((install_errors++))
466 +
            # No existing .zshrc, create new one
467 +
            print_status "No existing .zshrc found, creating new one"
468 +
            if cp "$TEMP_DIR/.zshrc" "$HOME/"; then
469 +
                print_success "Installed .zshrc"
470 +
            else
471 +
                print_error "Failed to install .zshrc"
472 +
                ((install_errors++))
473 +
            fi
429 474
        fi
430 475
    else
431 476
        print_error ".zshrc not found in downloaded files: $TEMP_DIR/.zshrc"
432 477
        ((install_errors++))
433 478
    fi
434 479
435 -
    # Install ghostty config
480 +
    # Install ghostty config (keep existing logic for replacement)
436 481
    if [ -f "$TEMP_DIR/config" ]; then
437 482
        print_debug "Installing ghostty config to $HOME/.config/ghostty/"
438 483
        mkdir -p "$HOME/.config/ghostty"
484 +
485 +
        if [ -f "$HOME/.config/ghostty/config" ]; then
486 +
            print_status "Existing Ghostty config found, it will be replaced"
487 +
            print_status "(Previous config was backed up)"
488 +
        fi
489 +
439 490
        if cp "$TEMP_DIR/config" "$HOME/.config/ghostty/"; then
440 491
            print_success "Installed Ghostty config"
441 492
        else