#terminal-colors #background-color #color-scheme #foreground #osc #determine #dark

terminal-colorsaurus

Determines the background and foreground color of the terminal

11 unstable releases (3 breaking)

new 0.4.1 May 18, 2024
0.4.0 May 7, 2024
0.3.3 Mar 16, 2024
0.3.1 Feb 8, 2024
0.1.0 Jan 20, 2024

#149 in Command-line interface

Download history 8/week @ 2024-01-27 10/week @ 2024-02-03 5/week @ 2024-02-17 13/week @ 2024-02-24 11/week @ 2024-03-02 201/week @ 2024-03-09 1783/week @ 2024-03-16 749/week @ 2024-03-23 605/week @ 2024-03-30 567/week @ 2024-04-06 616/week @ 2024-04-13 533/week @ 2024-04-20 566/week @ 2024-04-27 1024/week @ 2024-05-04 430/week @ 2024-05-11

2,638 downloads per month
Used in git-delta

MIT/Apache

42KB
833 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?».

Windows is unfortunately not supported.

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.8–11MB
~84K SLoC