Skip to main content

Pretty 🌸 Terminals

Run Tests, Build Wheels, & Publish to PyPI Publish to GitHub Pages

Pretty 🌸 Tty

[ Docs.rs | GitHub Pages | Rust Crate | Repository ]

Prettytty is a lightweight and flexible terminal library for Rust that has only one low-level dependency, i.e., libc on Unix and windows-sys on Windows. Its API is clean and simple: Open a Connection to the terminal and share it across threads as needed. Write Commands to Output. Read Query responses from Input. Scan::read_token takes care of low-level UTF-8 and ANSI escape sequence decoding and Query::parse turns token payloads into objects. A cmd library with 70+ built-in commands covers basic needs and then some.


Pretty 🌸 Pretty:

[ Docs.rs | GitHub Pages | Rust Crate | Python Package | Repository ]

🎖️ As featured on Real Python #211

🎖️ Inspired iTerm2's color preferences

Prettypretty is a Rust library with optional Python bindings that applies 2020s color science to 1970s terminals to facilitate scalable user interfaces. However, instead of progressive enhancement, it primarily relies on graceful degradation from high-resolution colors down to more limited terminal colors.

The three steps for better terminal styles are:

  1. Fluently declare high-resolution styles.
  2. Let prettypretty adjust styles to terminal capabilities and user preferences at program startup.
  3. Use adjusted styles at will.

Prettypretty seamlessly integrates with prettytty for querying the terminal for its current color theme. It then uses said color theme to produce more accurate results when converting high resultion colors down to 256 or 16 terminal colors. The integration also is entirely optional, controlled by the tty feature, and fairly small, requiring about 80 lines of code for Theme::query. Hence integration with another terminal library should be easy enough.

As far as colors are concerned, prettypretty comes with all the expressivity and convenience of high-resolution, floating point colors and color spaces, including the perceptually uniform Oklab, whether in Cartesian or polar form, with original or revised lightness. It further implements state-of-the-art algorithms for gamut-mapping, color interpolation, perceptual contrast, as well as its own hue- and lightness-based downsampling for optimal selection of ANSI colors.

Python Integration

The optional Python integration is enabled with the pyffi feature flag and relies on PyO3 and Maturin for building an extension module with the same functionality. Only where the Rust library uses trait implementations, the Python module uses dedicated methods. While prettytty takes care of terminal access for Rust, the Python version of prettypretty has its own terminal abstraction, with its own Pythonic interface.

Scripts Using Prettypretty

Besides the documentation, a good starting point for familiarizing yourself with prettypretty are the scripts:

  • prettypretty.progress illustrates the library's use on the example of a progress bar in less than 100 lines of Python. The finished progress bar is shown below for both light and dark themes.

    a complete, green progress bar under light mode a complete, green progress bar under dark mode

  • prettypretty.plot charts colors on the chroma/hue plane of Oklab, if you don't feed it colors defaulting to your terminal's current color scheme. Here's the one for the basic theme in Apple's Terminal.app:

    colors from the basic theme for Apple's Terminal.app in Oklch

  • prettypretty.grid visualizes perceptual contrast and color downsampling strategies, exhaustively for the 6x6x6 RGB cube embedded in 8-bit color and selectively for 32x32 slices through the much bigger 24-bit RGB cube.

    a grid visualizing the 6x6x6 embedded RGB cube

  • prettypretty.viz3d traces the boundaries of the visual gamut in 3D and saves the corresponding point cloud or mesh in PLY format. The screenshot below shows Vedo's rendering.

    a 3D visualization of the gamut for visible light,
somewhat shaped like a fat, squat hot pocket

Acknowledgements

I wrote much of prettypretty over a two-month period in 2024. Twice. I first implemented the core color routines in Python and then I did so again in Rust. At this point, only the Rust version survives. But Python remains a tier-1 runtime target for prettypretty. Two things really helped with getting this project started. First, I had been toying with different approaches to terminal styles for a while and knew what I was looking for. Second, I benefitted tremendously from Lea Verou's and Chris Lilley's work on the Color.js library and CSS Color 4 specification. Prettypretty directly reuses Color.js' formulae for conversion between color spaces and implements several CSS Color 4 algorithms.


Copyright 2024-2025 Robert Grimm. The code in this repository has been released as open source under the Apache 2.0 license.

Metadata

Release files for prettypretty 0.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prettypretty 0.12.0
File Size Uploaded
prettypretty-0.12.0.tar.gz 161.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for prettypretty 0.12.0
File
prettypretty-0.12.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
prettypretty-0.12.0-cp311-abi3-win32.whl CPython 3.11 abi3 Windows x86-32 Details
prettypretty-0.12.0-cp311-abi3-musllinux_1_2_x86_64.whl CPython 3.11 abi3 Linux musl 1.2+ x86-64 Details
prettypretty-0.12.0-cp311-abi3-musllinux_1_2_i686.whl CPython 3.11 abi3 Linux musl 1.2+ x86-32 Details
prettypretty-0.12.0-cp311-abi3-musllinux_1_2_armv7l.whl CPython 3.11 abi3 Linux musl 1.2+ ARMv7l Details
prettypretty-0.12.0-cp311-abi3-musllinux_1_2_aarch64.whl CPython 3.11 abi3 Linux musl 1.2+ ARM64 Details
prettypretty-0.12.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details
prettypretty-0.12.0-cp311-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl CPython 3.11 abi3 Linux glibc 2.17+ IBM System/390x Details
prettypretty-0.12.0-cp311-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl CPython 3.11 abi3 Linux glibc 2.17+ PowerPC 64-le Details
prettypretty-0.12.0-cp311-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl CPython 3.11 abi3 Linux glibc 2.17+ ARMv7l Details
prettypretty-0.12.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details
prettypretty-0.12.0-cp311-abi3-manylinux_2_5_i686.manylinux1_i686.whl CPython 3.11 abi3 Linux glibc 2.5+ x86-32 Details
prettypretty-0.12.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
prettypretty-0.12.0-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details

Total release size: 9.6 MB

Release files / prettypretty-0.12.0.tar.gz

Download URL prettypretty-0.12.0.tar.gz
Size 161.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e27349090c3bdf60de2e12ec2f820d00a863f21bb5a98cfaa9e5f75f9447eb7c
BLAKE2b-256 checksum
How to use checksums
fc4eec9fa627d2416175b1d8abd379c723cf3667d58d474458ac1fe8a6efa951
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.4

Release files / prettypretty-0.12.0-cp311-abi3-win_amd64.whl

Download URL prettypretty-0.12.0-cp311-abi3-win_amd64.whl
Size 459.3 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
03f420a8c3aa3201a8b1b9b57a87380020897ba822a06d025fe582fdd029d66a
BLAKE2b-256 checksum
How to use checksums
92a9595a3495e19fd7dab87c4dd962d203e3ef0afb7bec0437a58adbee9af209
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.4

Release files / prettypretty-0.12.0-cp311-abi3-win32.whl

Download URL prettypretty-0.12.0-cp311-abi3-win32.whl
Size 442.9 kB
Tags CPython 3.11 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
b355edf54ac87fa7a76fa7ec03bc8287c7353e8d6972b522a487b234f801a87a
BLAKE2b-256 checksum
How to use checksums
b98d8b7ca7f4be1929a42e96805bd3353f69819738bddc48dd0f1aa37487b5de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.4

Release files / prettypretty-0.12.0-cp311-abi3-musllinux_1_2_x86_64.whl

Download URL prettypretty-0.12.0-cp311-abi3-musllinux_1_2_x86_64.whl
Size 803.0 kB
Tags CPython 3.11 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
fae2b48cdcd13e445c241222e1ceb17b508d3ab1657c1658a1655fa38593c2d2
BLAKE2b-256 checksum
How to use checksums
13a4a98755e9466982da6c6e27c8a3761a93df161ce74b27defac202029ca99f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.4

Release files / prettypretty-0.12.0-cp311-abi3-musllinux_1_2_i686.whl

Download URL prettypretty-0.12.0-cp311-abi3-musllinux_1_2_i686.whl
Size 842.9 kB
Tags CPython 3.11 Linux musl 1.2+ x86-32 abi3
SHA-256 checksum
How to use checksums
1cba2f291f71e9d220eb96014627564a1b1c88bb9f0322951197188a464b573b
BLAKE2b-256 checksum
How to use checksums
d31847461cc286ae7a2362c6d53e9f16471459152f4a7ea60699c719741a1b26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.4

Release files / prettypretty-0.12.0-cp311-abi3-musllinux_1_2_armv7l.whl

Download URL prettypretty-0.12.0-cp311-abi3-musllinux_1_2_armv7l.whl
Size 903.4 kB
Tags CPython 3.11 Linux musl 1.2+ ARMv7l abi3
SHA-256 checksum
How to use checksums
16d2fc5cf3419314a5aa72fa9e5bbdf158b2fb187796cc5dd5360368e5ac0253
BLAKE2b-256 checksum
How to use checksums
8444036dcdfbcdf77b11e34b4741777346d7395cf2080e7f5153ca49e386e557
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.4

Release files / prettypretty-0.12.0-cp311-abi3-musllinux_1_2_aarch64.whl

Download URL prettypretty-0.12.0-cp311-abi3-musllinux_1_2_aarch64.whl
Size 802.5 kB
Tags CPython 3.11 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
768b14d79383827d995ea9e44d54d0a9fe60148a342c9ead9ccd257b20989ab7
BLAKE2b-256 checksum
How to use checksums
feb0d7203dd7d8981e34e2d22a68ab996eb66efe7d2621ed53cd692302a68ed0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.4

Release files / prettypretty-0.12.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL prettypretty-0.12.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 632.8 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
64fb0ea0337e54dc84e531c65cae6f40492856bb7fbe78368fb541538cb568de
BLAKE2b-256 checksum
How to use checksums
37e85b47b1abd28e1429eadf142bc62300c70d64e06c5b414dcfbd4e71daea7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.4

Release files / prettypretty-0.12.0-cp311-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl

Download URL prettypretty-0.12.0-cp311-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Size 663.4 kB
Tags CPython 3.11 Linux glibc 2.17+ IBM System/390x abi3
SHA-256 checksum
How to use checksums
4463bd454471c18b5a9e2e807eec7ad097c507707cff82a45fe41dbbd14e5573
BLAKE2b-256 checksum
How to use checksums
5d26519c00a2f7f6645145e29fcc5fa8bcf19dfbc06a54bfc2a984ed57638bdd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.4

Release files / prettypretty-0.12.0-cp311-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl

Download URL prettypretty-0.12.0-cp311-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Size 751.4 kB
Tags CPython 3.11 Linux glibc 2.17+ PowerPC 64-le abi3
SHA-256 checksum
How to use checksums
7122e5ca90d0a4558691548f5851f763d1c352e09768fdcb648f24d563bb63cb
BLAKE2b-256 checksum
How to use checksums
a290f062e392f81494d6e06399abc04812849976d8f88afce4bc57f6e3134d04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.4

Release files / prettypretty-0.12.0-cp311-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl

Download URL prettypretty-0.12.0-cp311-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Size 639.4 kB
Tags CPython 3.11 Linux glibc 2.17+ ARMv7l abi3
SHA-256 checksum
How to use checksums
250d263af4b091c7030208a47dbe839db6d9ebd12a9417ea8838baedf72518a5
BLAKE2b-256 checksum
How to use checksums
6a5e2f637ae5f5e8ddb46875d9f2406add4fc659aa0c10a08b01ae18a03edc7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.4

Release files / prettypretty-0.12.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL prettypretty-0.12.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 623.7 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
792df54bf580dda620aa57ad1648388156cc5a2938055118941592d1a7948b2c
BLAKE2b-256 checksum
How to use checksums
9d8f3189343ee206679cbaf0257d28726c578ab331d8ca4a1bde514734098907
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.4

Release files / prettypretty-0.12.0-cp311-abi3-manylinux_2_5_i686.manylinux1_i686.whl

Download URL prettypretty-0.12.0-cp311-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Size 680.1 kB
Tags CPython 3.11 Linux glibc 2.5+ x86-32 abi3
SHA-256 checksum
How to use checksums
c265c02fc51cbc4b69aba062fbc35a8b0f90c8de5aa43f4f53bef40508486f57
BLAKE2b-256 checksum
How to use checksums
71ca68246b327ab62adf11c67ac5a595b52d1ff17815d1b581be27fcf3d61aea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.4

Release files / prettypretty-0.12.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL prettypretty-0.12.0-cp311-abi3-macosx_11_0_arm64.whl
Size 582.6 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a4afc4ac3eb8fbfeedea502b5e2d716f1c668fda48d5622de57c4eeff00510b5
BLAKE2b-256 checksum
How to use checksums
a7b0f418c1c6228e286ee8e295f72e81c0c34f26e6a4ca6985364d49cdedbda6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.4

Release files / prettypretty-0.12.0-cp311-abi3-macosx_10_12_x86_64.whl

Download URL prettypretty-0.12.0-cp311-abi3-macosx_10_12_x86_64.whl
Size 614.7 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
707d3f99473023bc365f850376adad0e2d005958fbc9dcfd066cb601765fa14d
BLAKE2b-256 checksum
How to use checksums
13ebb94b831a3e7accbe121c7367607d334aa0734fc4593533bae103ec542214
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.4

Release history Release notifications | RSS feed

This release

0.12.0 This release

15 release files

0.9.0

1 release file

0.8.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page