#terminal-colors #color-scheme #light #dark #terminal

terminal-colorsaurus

Determines the background and foreground color of the terminal

16 releases

new 0.4.5 Nov 19, 2024
0.4.4 Jul 18, 2024
0.4.3 Jun 10, 2024
0.3.3 Mar 16, 2024

#142 in Command-line interface

Download history 1039/week @ 2024-07-30 1068/week @ 2024-08-06 1613/week @ 2024-08-13 1336/week @ 2024-08-20 829/week @ 2024-08-27 1057/week @ 2024-09-03 972/week @ 2024-09-10 652/week @ 2024-09-17 665/week @ 2024-09-24 1011/week @ 2024-10-01 719/week @ 2024-10-08 523/week @ 2024-10-15 603/week @ 2024-10-22 656/week @ 2024-10-29 1057/week @ 2024-11-05 1334/week @ 2024-11-12

3,741 downloads per month
Used in git-delta

MIT/Apache

46KB
918 lines

terminal-colorsaurus 🦕

Docs Crate Version

Determines the background and foreground color of the terminal using the OSC 10 and OSC 11 escape codes.

This library helps answer the question «Is this terminal dark or light?».

Works in all major terminals including Windows Terminal (starting with v1.22).

Example

use terminal_colorsaurus::{color_scheme, QueryOptions, ColorScheme};

match color_scheme(QueryOptions::default()).unwrap() {
    ColorScheme::Dark => { /* ... */ },
    ColorScheme::Light => { /* ... */ },
}

Docs

Inspiration

This crate borrows ideas from many other projects. This list is by no means exhaustive.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0.4–9.5MB
~74K SLoC