#color #programming-language #github #query-language #linguist #xterm #extension

bin+lib linguist-termcolor

查询 GitHub 库中的编程语言颜色

3 个版本

0.1.2 2024 年 5 月 27 日
0.1.1 2024 年 5 月 25 日
0.1.0 2024 年 5 月 25 日

669开发工具 中排名

Download history 332/week @ 2024-05-24 35/week @ 2024-05-31 6/week @ 2024-06-07 2/week @ 2024-06-14

每月 86 次下载

MIT/Apache

20KB
219

linguist-termcolor

查询 GitHub 的 Linguist 库中的编程语言颜色。

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

我需要 xterm 颜色为 Spaceship 😎,但后来变得复杂了。


lib.rs:

查询 GitHub 的 Linguist 库中的编程语言颜色。

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

您可以使用语言名称或文件扩展名进行查询。

xterm 颜色和颜色距离

为了找到最接近的 xterm 颜色,可以使用 --colors/-c 选项来指定使用 颜色模型颜色空间 计算颜色差异的方法,使用 color_art::distance_with

默认是 RGB,但实际上可能不会在人类感知方面产生最佳结果。为了找到看起来最接近的颜色,CIELAB 是一个合理的选择;使用 -c lab。请参阅 ColorSpace 了解可用的选项。

例如,以下分别使用 RGBCMYKCIELAB"python" 的不同结果。

$ 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

依赖项

~9–24MB
~325K SLoC