1
Fork 0
mirror of https://github.com/RGBCube/ThemeNix synced 2026-01-15 09:41:01 +00:00
ThemeNix/visualize.nu
2023-12-04 10:02:06 +03:00

31 lines
674 B
Text
Executable file

#!/usr/bin/env nu
def complete [] {
ls themes
}
# Visualizes a theme in the terminal.
def main [
theme: string@complete # The path to the theme to visualize.
] {
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 key value
| each {|it|
let color_hex = "#" + $it.value
let color = { bg: $color_hex }
echo $"($it.key) ($color_hex): (ansi $color) (ansi reset)"
}
$"\n($theme.name) by ($theme.author)"
}