chore: Updated install script on site
528b73a9
1 file(s) · +83 −17
| 82 | 82 | print_error "curl is not installed. Please install it first." |
|
| 83 | 83 | exit 1 |
|
| 84 | 84 | fi |
|
| 85 | - | print_success "curl found at: $(which curl)" |
|
| 86 | - | ||
| 87 | - | print_debug "Checking curl version..." |
|
| 88 | - | curl --version | head -1 |
|
| 89 | 85 | } |
|
| 90 | 86 | ||
| 91 | 87 | # Create temporary directory for downloads |
|
| 197 | 193 | local files=( |
|
| 198 | 194 | ".zshrc" |
|
| 199 | 195 | "config" |
|
| 196 | + | "dark.tmTheme" |
|
| 200 | 197 | ) |
|
| 201 | 198 | ||
| 202 | 199 | local success_count=0 |
|
| 206 | 203 | ||
| 207 | 204 | for file in "${files[@]}"; do |
|
| 208 | 205 | print_debug "=== Processing file $((success_count + 1))/$total_files: $file ===" |
|
| 209 | - | print_status "Attempting to download: $file" |
|
| 210 | 206 | ||
| 211 | 207 | # Disable error exit temporarily for this specific operation |
|
| 212 | 208 | set +e |
|
| 259 | 255 | mkdir -p "$TEMP_DIR/assets" |
|
| 260 | 256 | font_dest="$TEMP_DIR/assets/$font_filename" |
|
| 261 | 257 | ||
| 262 | - | if curl -L -f -s -w "HTTP_CODE:%{http_code};SIZE:%{size_download}" -o "$font_dest" "$font_url" 2>/dev/null; then |
|
| 258 | + | if curl -L -f -s -o "$font_dest" "$font_url" 2>/dev/null; then |
|
| 263 | 259 | local file_size=$(wc -c < "$font_dest" 2>/dev/null || echo "0") |
|
| 264 | 260 | print_success "Downloaded CommitMono Nerd Font (${file_size} bytes)" |
|
| 265 | 261 | ||
| 327 | 323 | "starship" |
|
| 328 | 324 | "eza" |
|
| 329 | 325 | "zoxide" |
|
| 326 | + | "aichat" |
|
| 327 | + | "btop" |
|
| 330 | 328 | ) |
|
| 331 | 329 | ||
| 332 | 330 | local cask_packages=( |
|
| 333 | 331 | "ghostty" |
|
| 334 | 332 | ) |
|
| 335 | - | ||
| 336 | - | # Update Homebrew first |
|
| 337 | - | print_status "Updating Homebrew..." |
|
| 338 | 333 | ||
| 339 | 334 | # Install regular packages |
|
| 340 | 335 | for package in "${packages[@]}"; do |
|
| 410 | 405 | fi |
|
| 411 | 406 | } |
|
| 412 | 407 | ||
| 408 | + | check_darkmatter_in_zshrc() { |
|
| 409 | + | local zshrc_file="$1" |
|
| 410 | + | ||
| 411 | + | if [ ! -f "$zshrc_file" ]; then |
|
| 412 | + | return 1 # File doesn't exist |
|
| 413 | + | fi |
|
| 414 | + | ||
| 415 | + | # Look for our marker comment |
|
| 416 | + | if grep -q "# Darkmatter Terminal Configuration" "$zshrc_file" 2>/dev/null; then |
|
| 417 | + | return 0 # Already present |
|
| 418 | + | else |
|
| 419 | + | return 1 # Not present |
|
| 420 | + | fi |
|
| 421 | + | } |
|
| 422 | + | ||
| 423 | + | ||
| 413 | 424 | # Copy downloaded configuration files to their destinations |
|
| 414 | 425 | install_configs() { |
|
| 415 | 426 | print_status "Installing configuration files..." |
|
| 416 | 427 | ||
| 417 | 428 | local install_errors=0 |
|
| 418 | 429 | ||
| 419 | - | # Install .zshrc |
|
| 430 | + | # Handle .zshrc installation |
|
| 420 | 431 | if [ -f "$TEMP_DIR/.zshrc" ]; then |
|
| 421 | - | print_debug "Installing .zshrc to $HOME/" |
|
| 422 | - | if cp "$TEMP_DIR/.zshrc" "$HOME/"; then |
|
| 423 | - | print_success "Installed .zshrc" |
|
| 432 | + | if [ -f "$HOME/.zshrc" ]; then |
|
| 433 | + | # Existing .zshrc found |
|
| 434 | + | print_status "Existing .zshrc found, checking for Darkmatter configuration..." |
|
| 435 | + | ||
| 436 | + | if check_darkmatter_in_zshrc "$HOME/.zshrc"; then |
|
| 437 | + | print_warning "Darkmatter configuration already exists in .zshrc" |
|
| 438 | + | print_status "Skipping .zshrc modification to avoid duplicates" |
|
| 439 | + | else |
|
| 440 | + | print_status "Appending Darkmatter configuration to existing .zshrc" |
|
| 441 | + | ||
| 442 | + | # Add a separator and our config |
|
| 443 | + | { |
|
| 444 | + | echo "" |
|
| 445 | + | echo "# =============================================" |
|
| 446 | + | echo "# Darkmatter Terminal Configuration" |
|
| 447 | + | echo "# Added by Darkmatter installer on $(date)" |
|
| 448 | + | echo "# =============================================" |
|
| 449 | + | echo "" |
|
| 450 | + | cat "$TEMP_DIR/.zshrc" |
|
| 451 | + | } >> "$HOME/.zshrc" && { |
|
| 452 | + | print_success "Successfully appended Darkmatter configuration to .zshrc" |
|
| 453 | + | } || { |
|
| 454 | + | print_error "Failed to append to existing .zshrc" |
|
| 455 | + | ((install_errors++)) |
|
| 456 | + | } |
|
| 457 | + | fi |
|
| 424 | 458 | else |
|
| 425 | - | print_error "Failed to install .zshrc" |
|
| 426 | - | ((install_errors++)) |
|
| 459 | + | # No existing .zshrc, create new one |
|
| 460 | + | print_status "No existing .zshrc found, creating new one" |
|
| 461 | + | if cp "$TEMP_DIR/.zshrc" "$HOME/"; then |
|
| 462 | + | print_success "Installed .zshrc" |
|
| 463 | + | else |
|
| 464 | + | print_error "Failed to install .zshrc" |
|
| 465 | + | ((install_errors++)) |
|
| 466 | + | fi |
|
| 427 | 467 | fi |
|
| 428 | 468 | else |
|
| 429 | 469 | print_error ".zshrc not found in downloaded files: $TEMP_DIR/.zshrc" |
|
| 430 | 470 | ((install_errors++)) |
|
| 431 | 471 | fi |
|
| 432 | 472 | ||
| 433 | - | # Install ghostty config |
|
| 473 | + | # Install ghostty config (keep existing logic for replacement) |
|
| 434 | 474 | if [ -f "$TEMP_DIR/config" ]; then |
|
| 435 | 475 | print_debug "Installing ghostty config to $HOME/.config/ghostty/" |
|
| 436 | 476 | mkdir -p "$HOME/.config/ghostty" |
|
| 477 | + | ||
| 478 | + | if [ -f "$HOME/.config/ghostty/config" ]; then |
|
| 479 | + | print_status "Existing Ghostty config found, it will be replaced" |
|
| 480 | + | print_status "(Previous config was backed up)" |
|
| 481 | + | fi |
|
| 482 | + | ||
| 437 | 483 | if cp "$TEMP_DIR/config" "$HOME/.config/ghostty/"; then |
|
| 438 | 484 | print_success "Installed Ghostty config" |
|
| 439 | 485 | else |
|
| 442 | 488 | fi |
|
| 443 | 489 | else |
|
| 444 | 490 | print_error "Ghostty config not found in downloaded files: $TEMP_DIR/config" |
|
| 491 | + | ((install_errors++)) |
|
| 492 | + | fi |
|
| 493 | + | ||
| 494 | + | # Install aichat theme |
|
| 495 | + | if [ -f "$TEMP_DIR/dark.tmTheme" ]; then |
|
| 496 | + | print_debug "Installing aichat theme to $HOME/Library/Application Support/aichat/" |
|
| 497 | + | mkdir -p "$HOME/Library/Application Support/aichat" |
|
| 498 | + | ||
| 499 | + | if [ -f "$HOME/Library/Application Support/aichat/dark.tmTheme" ]; then |
|
| 500 | + | print_status "Existing aichat theme found, it will be replaced" |
|
| 501 | + | fi |
|
| 502 | + | ||
| 503 | + | if cp "$TEMP_DIR/dark.tmTheme" "$HOME/Library/Application Support/aichat/"; then |
|
| 504 | + | print_success "Installed aichat theme" |
|
| 505 | + | else |
|
| 506 | + | print_error "Failed to install aichat theme" |
|
| 507 | + | ((install_errors++)) |
|
| 508 | + | fi |
|
| 509 | + | else |
|
| 510 | + | print_error "aichat theme not found in downloaded files: $TEMP_DIR/dark.tmTheme" |
|
| 445 | 511 | ((install_errors++)) |
|
| 446 | 512 | fi |
|
| 447 | 513 | ||
| 542 | 608 | ||
| 543 | 609 | check_dependencies |
|
| 544 | 610 | setup_temp_dir |
|
| 611 | + | install_packages |
|
| 545 | 612 | test_github_connection |
|
| 546 | 613 | download_configs |
|
| 547 | 614 | download_and_install_font |
|
| 548 | - | install_packages |
|
| 549 | 615 | backup_configs |
|
| 550 | 616 | install_configs |
|
| 551 | 617 | set_default_shell |
|