mirror of
https://github.com/RGBCube/ThemeNix
synced 2025-07-28 08:57:46 +00:00
Add visualize script
This commit is contained in:
parent
f51f60249b
commit
f52e118155
3 changed files with 40 additions and 1 deletions
|
@ -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>
|
||||||
|
|
||||||
|
|
|
@ -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
33
visualize.nu
Executable 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)"
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue