catppuccin.extras.rich_ctp

Rich themes for all Catppuccin flavors.

Install Catppuccin with the rich feature to include the relevant dependencies:

pip install catppuccin[rich]

Pass one of the four flavors as your Console theme:

from rich.console import Console
from catppuccin.extras.rich_ctp import latte, frappe, macchiato, mocha

c = Console(theme=mocha)
c.print("Hello", style="yellow")
 1"""Rich themes for all Catppuccin flavors.
 2
 3Install Catppuccin with the `rich` feature to include the relevant dependencies:
 4
 5```
 6pip install catppuccin[rich]
 7```
 8
 9Pass one of the four flavors as your `Console` theme:
10
11```python
12from rich.console import Console
13from catppuccin.extras.rich_ctp import latte, frappe, macchiato, mocha
14
15c = Console(theme=mocha)
16c.print("Hello", style="yellow")
17```
18"""
19
20from rich.theme import Theme
21
22from catppuccin import PALETTE
23from catppuccin.models import FlavorColors
24
25
26def _make_theme(colors: FlavorColors) -> Theme:
27    return Theme(
28        {
29            "rosewater": colors.rosewater.hex,
30            "flamingo": colors.flamingo.hex,
31            "pink": colors.pink.hex,
32            "mauve": colors.mauve.hex,
33            "red": colors.red.hex,
34            "maroon": colors.maroon.hex,
35            "peach": colors.peach.hex,
36            "yellow": colors.yellow.hex,
37            "green": colors.green.hex,
38            "teal": colors.teal.hex,
39            "sky": colors.sky.hex,
40            "sapphire": colors.sapphire.hex,
41            "blue": colors.blue.hex,
42            "lavender": colors.lavender.hex,
43            "text": colors.text.hex,
44            "subtext1": colors.subtext1.hex,
45            "subtext0": colors.subtext0.hex,
46            "overlay2": colors.overlay2.hex,
47            "overlay1": colors.overlay1.hex,
48            "overlay0": colors.overlay0.hex,
49            "surface2": colors.surface2.hex,
50            "surface1": colors.surface1.hex,
51            "surface0": colors.surface0.hex,
52            "base": colors.base.hex,
53            "mantle": colors.mantle.hex,
54            "crust": colors.crust.hex,
55        },
56    )
57
58
59latte = _make_theme(PALETTE.latte.colors)
60frappe = _make_theme(PALETTE.frappe.colors)
61macchiato = _make_theme(PALETTE.macchiato.colors)
62mocha = _make_theme(PALETTE.mocha.colors)