|
4 | 4 | if [ "$#" -lt 1 ]; then |
5 | 5 | # Print usage information to standard error. |
6 | 6 | echo "Error: No application specified." >&2 |
7 | | - echo "Usage: $0 {kitty|ghostty|foot|alacritty|wezterm|fuzzel|walker|pywalfox|cava|yazi|labwc|niri|hyprland|sway|scroll|mango|btop|zathura} [dark|light]" >&2 |
| 7 | + echo "Usage: $0 {kitty|ghostty|foot|alacritty|wezterm|starship|fuzzel|walker|pywalfox|cava|yazi|labwc|niri|hyprland|sway|scroll|mango|btop|zathura} [dark|light]" >&2 |
8 | 8 | exit 1 |
9 | 9 | fi |
10 | 10 |
|
@@ -534,6 +534,54 @@ zathura) |
534 | 534 | done |
535 | 535 | ;; |
536 | 536 |
|
| 537 | +starship) |
| 538 | + PALETTE_FILE="$HOME/.cache/noctalia/starship-palette.toml" |
| 539 | + CONFIG_FILE="$HOME/.config/starship.toml" |
| 540 | + |
| 541 | + # Check if the generated palette file exists |
| 542 | + if [ ! -f "$PALETTE_FILE" ]; then |
| 543 | + echo "Error: Starship palette file not found at $PALETTE_FILE" >&2 |
| 544 | + exit 1 |
| 545 | + fi |
| 546 | + |
| 547 | + MARKER_BEGIN="# >>> NOCTALIA STARSHIP PALETTE >>>" |
| 548 | + MARKER_END="# <<< NOCTALIA STARSHIP PALETTE <<<" |
| 549 | + |
| 550 | + # Create config file if it doesn't exist |
| 551 | + if [ ! -f "$CONFIG_FILE" ]; then |
| 552 | + mkdir -p "$(dirname "$CONFIG_FILE")" |
| 553 | + echo 'palette = "noctalia"' > "$CONFIG_FILE" |
| 554 | + echo "" >> "$CONFIG_FILE" |
| 555 | + echo "$MARKER_BEGIN" >> "$CONFIG_FILE" |
| 556 | + cat "$PALETTE_FILE" >> "$CONFIG_FILE" |
| 557 | + echo "$MARKER_END" >> "$CONFIG_FILE" |
| 558 | + exit 0 |
| 559 | + fi |
| 560 | + |
| 561 | + # 1. Set palette = "noctalia" at top level |
| 562 | + if grep -qE '^palette\s*=' "$CONFIG_FILE"; then |
| 563 | + sed -i -E 's/^palette\s*=.*/palette = "noctalia"/' "$CONFIG_FILE" |
| 564 | + else |
| 565 | + # Insert after schema line if present, otherwise at line 1 |
| 566 | + if grep -qE '^\"\$schema\"' "$CONFIG_FILE"; then |
| 567 | + sed -i '/^\"\$schema\"/a palette = "noctalia"' "$CONFIG_FILE" |
| 568 | + else |
| 569 | + sed -i '1i palette = "noctalia"' "$CONFIG_FILE" |
| 570 | + fi |
| 571 | + fi |
| 572 | + |
| 573 | + # 2. Remove existing noctalia palette block (between markers) |
| 574 | + if grep -qF "$MARKER_BEGIN" "$CONFIG_FILE"; then |
| 575 | + sed -i "/$(echo "$MARKER_BEGIN" | sed 's/[[\.*^$()+?{|]/\\&/g')/,/$(echo "$MARKER_END" | sed 's/[[\.*^$()+?{|]/\\&/g')/d" "$CONFIG_FILE" |
| 576 | + fi |
| 577 | + |
| 578 | + # 3. Append the new palette block |
| 579 | + echo "" >> "$CONFIG_FILE" |
| 580 | + echo "$MARKER_BEGIN" >> "$CONFIG_FILE" |
| 581 | + cat "$PALETTE_FILE" >> "$CONFIG_FILE" |
| 582 | + echo "$MARKER_END" >> "$CONFIG_FILE" |
| 583 | + ;; |
| 584 | + |
537 | 585 | *) |
538 | 586 | # Handle unknown application names. |
539 | 587 | echo "Error: Unknown application '$APP_NAME'." >&2 |
|
0 commit comments