1
Fork 0
mirror of https://github.com/RGBCube/ThemeNix synced 2025-07-28 00:47:44 +00:00

Add visualize script

This commit is contained in:
RGBCube 2023-12-02 22:58:11 +03:00
parent f51f60249b
commit f52e118155
No known key found for this signature in database
3 changed files with 40 additions and 1 deletions

View file

@ -34,6 +34,12 @@ let
in {} in {}
``` ```
You can also use the `visualize.nu` script to visualize any theme in the terminal:
```nu
./visualize.nu themes/chalk.nix
```
<details> <details>
<summary>All themes</summary> <summary>All themes</summary>

View file

@ -2,7 +2,7 @@
def theme-to-nix [ def theme-to-nix [
theme: record, # The theme to convert to Nix. theme: record, # The theme to convert to Nix.
] { ] -> nothing {
$theme $theme
| items { |key, value| | items { |key, value|
let key = match $key { let key = match $key {

33
visualize.nu Executable file
View file

@ -0,0 +1,33 @@
#!/usr/bin/env nu
# Visualizes a theme in the terminal.
def main [
theme: string, # The path to the theme to visualize.
] -> nothing {
if not ($env.COLORTERM | str contains "truecolor") {
echo "your terminal emulator doesn't support truecolor, colors may be wrong\n"
}
let theme = open $theme
| str replace --all ";" ","
| str replace --all "=" ":"
| from json
$theme
| reject name author
| transpose name value
| each { |it|
let hex = ("0x" + $in.value) | into int
let r = $hex bit-shr 16
let g = $hex bit-shr 8 bit-and 0xFF
let b = $hex bit-and 0xFF
$it | merge { value: $"\\033[48;2;($r);($g);($b)m" }
}
| each { |it|
^echo -e $"($it.name): ($it.value) \\033[0m"
}
$"\n($theme.name) by ($theme.author)"
}