Crate linguist_termcolor

Source
Expand description

Query GitHub’s Linguist library for colors for programming languages.

$ linguist-termcolor for rust
rgb #dea584 xterm 180 rust

You can query with language names or file extensions.

§xterm colors and color distances

For finding the nearest xterm colors, a --colors/-c option is available for specifying the color model or color space in which to calculate color differences using color_art::distance_with.

The default is RGB, which may not actually yield the best result in terms of human perception. For finding colors that “look” the closest, CIELAB is a reasonable choice; use it with -c lab. See ColorSpace for available choices.

For example, here are the different results for "python" using RGB, CMYK, and CIELAB, respectively.

$ linguist-termcolor -c rgb for python
rgb #3572a5 xterm 61 python
$ linguist-termcolor -c cmyk for python
rgb #3572a5 xterm 67 python
$ linguist-termcolor -c lab for python
rgb #3572a5 xterm 24 python

Structs§

ColorMap
Linguist
See https://github.com/github-linguist/linguist
TermColor