Created
March 3, 2026 17:43
-
-
Save joemccann/40d57dfdfbc6e3f3ef592a37dbb11646 to your computer and use it in GitHub Desktop.
Extract all Warp Themes from terminalcolors.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # sync-terminalcolors-themes.sh | |
| # | |
| # Scrapes https://terminalcolors.com for all available Warp terminal themes | |
| # and downloads them to ~/.warp/themes/. Idempotent — safe to run repeatedly. | |
| # New themes on the site will be picked up automatically. | |
| # | |
| # Usage: bash ~/.warp/scripts/sync-terminalcolors-themes.sh | |
| # | |
| set -euo pipefail | |
| BASE_URL="https://terminalcolors.com" | |
| DOWNLOAD_BASE="$BASE_URL/downloads/warp" | |
| DEST="$HOME/.warp/themes" | |
| mkdir -p "$DEST" | |
| echo "Fetching theme index from $BASE_URL ..." | |
| # Step 1: Get all top-level theme IDs from the homepage HTML. | |
| # Links appear as both /themes/{id}/ and /themes/{id}/{variant}/ — extract the theme ID from both. | |
| THEME_IDS=$(curl -sL "$BASE_URL" \ | |
| | grep -oE 'href="/themes/[a-z0-9-]+(/[a-z0-9-]+)?/"' \ | |
| | sed 's|href="/themes/||;s|/.*||' \ | |
| | sort -u) | |
| if [ -z "$THEME_IDS" ]; then | |
| echo "ERROR: Failed to scrape any theme IDs from $BASE_URL" >&2 | |
| exit 1 | |
| fi | |
| THEME_COUNT=$(echo "$THEME_IDS" | wc -l | tr -d ' ') | |
| echo "Found $THEME_COUNT top-level themes." | |
| # Step 2: For each theme, scrape its page to discover all variant slugs. | |
| DOWNLOAD_LIST=() | |
| for theme in $THEME_IDS; do | |
| VARIANTS=$(curl -sL "$BASE_URL/themes/$theme/" \ | |
| | grep -oE "href=\"/themes/$theme/[a-z0-9-]+/\"" \ | |
| | sed "s|href=\"/themes/$theme/||;s|/\"||" \ | |
| | sort -u) | |
| if [ -z "$VARIANTS" ]; then | |
| echo " WARNING: No variants found for '$theme', skipping." >&2 | |
| continue | |
| fi | |
| for variant in $VARIANTS; do | |
| DOWNLOAD_LIST+=("${theme}-${variant}") | |
| done | |
| done | |
| TOTAL=${#DOWNLOAD_LIST[@]} | |
| echo "Resolved $TOTAL theme variants total. Downloading..." | |
| # Step 3: Download each theme YAML. | |
| SUCCESS=0 | |
| FAIL=0 | |
| SKIPPED=0 | |
| for entry in "${DOWNLOAD_LIST[@]}"; do | |
| DEST_FILE="$DEST/$entry.yaml" | |
| # Skip if file already exists (use --force or -f flag to re-download all) | |
| if [ "${1:-}" != "--force" ] && [ "${1:-}" != "-f" ] && [ -f "$DEST_FILE" ]; then | |
| SKIPPED=$((SKIPPED + 1)) | |
| continue | |
| fi | |
| HTTP_CODE=$(curl -sL -w "%{http_code}" -o "$DEST_FILE" "$DOWNLOAD_BASE/$entry.yaml") | |
| if [ "$HTTP_CODE" = "200" ]; then | |
| SUCCESS=$((SUCCESS + 1)) | |
| else | |
| FAIL=$((FAIL + 1)) | |
| echo " FAILED ($HTTP_CODE): $entry" >&2 | |
| rm -f "$DEST_FILE" | |
| fi | |
| done | |
| echo "" | |
| echo "=== Sync complete ===" | |
| echo " New downloads: $SUCCESS" | |
| echo " Already existed (skipped): $SKIPPED" | |
| echo " Failed: $FAIL" | |
| echo " Total variants: $TOTAL" | |
| echo "" | |
| echo "Themes saved to: $DEST" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment