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

terminal-colorsaurus

Determines the background and foreground color of the terminal

18 releases

0.4.7 Nov 26, 2024
0.4.4 Jul 18, 2024
0.3.3 Mar 16, 2024

#102 in Command-line interface

Download history 1247/week @ 2024-08-21 829/week @ 2024-08-28 1084/week @ 2024-09-04 956/week @ 2024-09-11 626/week @ 2024-09-18 641/week @ 2024-09-25 1095/week @ 2024-10-02 630/week @ 2024-10-09 534/week @ 2024-10-16 592/week @ 2024-10-23 698/week @ 2024-10-30 1116/week @ 2024-11-06 1451/week @ 2024-11-13 1516/week @ 2024-11-20 1555/week @ 2024-11-27 888/week @ 2024-12-04

5,594 downloads per month
Used in git-delta

MIT/Apache

46KB
912 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.5–8.5MB
~69K SLoC