Convert RGB hex values to ANSI 256 color code in TOML document.
After Rust Installation,
$ cargo install --git https://github.com/koyeung/toml-rgb2ansi256.git
Helix supports both RGB truecolor and ANSI 256 color index in themes. However, some terminal emulators still have no truecolor support. Below command could convert the hex RGB values into ANSI 256 color code:
$ cp $HOMEBREW_PREFIX/opt/helix/libexec/runtime/themes/github_dark.toml .
$ tail github_dark.toml
"severe.muted" = "#db6d2866"
"severe.subtle" = "#db6d2826"
"sponsors.emphasis" = "#bf4b8a"
"sponsors.fg" = "#db61a2"
"sponsors.muted" = "#db61a266"
"sponsors.subtle" = "#db61a226"
"success.emphasis" = "#238636"
"success.fg" = "#3fb950"
"success.muted" = "#2ea04366"
"success.subtle" = "#2ea04326"
$
$ toml-rgb2ansi256 < github_dark.toml > github_dark_ansi256.toml
$
$ tail github_dark_ansi256.toml
"severe.muted" = "167"
"severe.subtle" = "167"
"sponsors.emphasis" = "132"
"sponsors.fg" = "169"
"sponsors.muted" = "169"
"sponsors.subtle" = "169"
"success.emphasis" = "29"
"success.fg" = "71"
"success.muted" = "71"
"success.subtle" = "71"
$
Put github_dark_ansi256.toml
into ~/.config/helix/themes/
. :theme
command should apply the theme with approximate colors.
Thanks to rgb2ansi256 for color code conversion and toml_edit for format-preserving parsing.
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
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.