#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 1172/week @ 2024-08-23 888/week @ 2024-08-30 1212/week @ 2024-09-06 681/week @ 2024-09-13 693/week @ 2024-09-20 565/week @ 2024-09-27 1194/week @ 2024-10-04 529/week @ 2024-10-11 642/week @ 2024-10-18 512/week @ 2024-10-25 669/week @ 2024-11-01 1498/week @ 2024-11-08 1542/week @ 2024-11-15 1240/week @ 2024-11-22 1502/week @ 2024-11-29 961/week @ 2024-12-06

5,460 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.4–8.5MB
~70K SLoC