$ show mbadolato/iTerm2-Color-Schemes
This repository is a curated collection of over 300 terminal color schemes (themes) and a comprehensive conversion toolchain that transforms a single source of truth (YAML + iTerm2 plist files) into configuration files for more than 20 terminal emulators, including Alacritty, Kitty, Windows Terminal, Xresources, Konsole, and many others. The core converter `tools/gen.py` reads source color data, applies WCAG contrast adjustments, and uses Jinja2 templates to generate output files. The repository also includes a terminal-based theme previewer, automated screenshot generation, and WCAG accessibility checks. It is a hybrid project: primarily a data collection with an ETL pipeline for multi-format export, but also contains application-level tools for preview and quality assurance. The codebase is well-organized, with reusable color science utilities (sRGB/P3 conversion, luminance, contrast ratio) and a template-driven generation architecture that can be adapted for other multi-format rendering tasks.
The LLM identified 5 files worth highlighting for reuse:
The main generator script that reads source color definitions (YAML and iTerm2 plist), applies WCAG contrast adjustments via `adjust_colors_for_wcag()`, converts between color spaces (sRGB, P3, hex, guint16), and renders output files using Jinja2 templates. The `Color` dataclass and `Theme` dataclass encapsulate color math and scheme metadata in a self-contained, reusable way. The fallback color map and cached properties demonstrate attention to edge cases.
A standalone CLI tool that evaluates all color schemes for WCAG contrast compliance. Contains reusable color science functions: `srgb_to_linear()`, `relative_luminance()`, `contrast_ratio()`, and `suggest_color()` which can be extracted and used in any color-related project. Outputs console, HTML, or Markdown reports. The contrast adjustment logic in `gen.py` relies on these same functions.
Renders a live, interactive preview of a color scheme in the terminal using truecolor ANSI escape sequences. The `render_preview()` function draws color swatches, semantic sample text, and full-width line illustrations. Implemented as a standalone Python package (`preview_theme/`) with `loader.py` for theme resolution and `colors.py` for color parsing. Demonstrates non-trivial terminal UI rendering techniques.
A PNG screenshot generator that renders each color theme into a styled terminal window image. The `PixFont` class implements custom bitmap font rendering from precomputed glyph maps, and `ConsoleScreenshotRenderer` composes the final preview with colored text, swatches, and a grid. Fully self-contained with no external image dependencies beyond Pillow. The `gen_font.py` companion creates font bitmaps programmatically.
A utility module for converting color values between hexadecimal strings, RGB tuples, guint16 arrays, and iTerm2 plist color dictionary format. Contains the `hex_to_rgb()`, `rgb_to_hex()`, `rgb_to_guint16()`, and `from_iterm_color_dict()` functions that are used across the codebase. Provides a clean, stateless API that can be reused in any color processing pipeline.