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

terminal-colorsaurus

Determines the background and foreground color of the terminal

9 releases

0.3.3 Mar 16, 2024
0.3.2 Mar 15, 2024
0.3.1 Feb 8, 2024
0.2.3 Feb 2, 2024
0.1.0 Jan 20, 2024

#196 in Command-line interface

Download history 9/week @ 2024-01-23 14/week @ 2024-01-30 4/week @ 2024-02-06 1/week @ 2024-02-13 5/week @ 2024-02-20 19/week @ 2024-02-27 9/week @ 2024-03-05 1322/week @ 2024-03-12 1083/week @ 2024-03-19 544/week @ 2024-03-26 535/week @ 2024-04-02

3,487 downloads per month
Used in git-delta

MIT/Apache

32KB
596 lines

terminal-colorsaurus 🦕

Docs Crate Version

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

This is useful for answering the question "Is this terminal dark or light?".

Windows is unfortunately not supported.

Example

use terminal_colorsaurus::{color_scheme, QueryOptions};

let colors = color_scheme(QueryOptions::default()).unwrap();
dbg!(colors.is_dark_on_light());

Docs

Wishlist

These are some features that I would like to include in this crate, but have not yet had the time to implement. PRs are welcome :)

  • A CLI tool version of this library.

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–10MB
~77K SLoC