1
Fork 0
mirror of https://github.com/RGBCube/ThemeNix synced 2025-07-28 17:07:46 +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

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)"
}