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

terminal-colorsaurus

Determines the background and foreground color of the terminal

10 unstable releases (3 breaking)

0.4.0 May 7, 2024
0.3.3 Mar 16, 2024
0.3.1 Feb 8, 2024
0.2.3 Feb 2, 2024
0.1.0 Jan 20, 2024

#159 in Command-line interface

Download history 14/week @ 2024-02-01 4/week @ 2024-02-08 3/week @ 2024-02-15 10/week @ 2024-02-22 12/week @ 2024-02-29 55/week @ 2024-03-07 1656/week @ 2024-03-14 855/week @ 2024-03-21 608/week @ 2024-03-28 571/week @ 2024-04-04 607/week @ 2024-04-11 529/week @ 2024-04-18 563/week @ 2024-04-25 1056/week @ 2024-05-02 374/week @ 2024-05-09

2,631 downloads per month
Used in git-delta

MIT/Apache

39KB
799 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–8.5MB
~72K SLoC