Skip to content

Conversation

scubacabra
Copy link
Contributor

this is very much a wip, but it is the closest i have ever been to conquering this script file.
it is just war, i was annoyed i could not figure it out. i have been wanting to figure out what is going on in this script for forever.

at the very least, it will probably teach me something i did not know about nushell!

it seemed like black magic but i figured there had to be a method to the madness and maybe one day i would figure it out.

this is so far what i have figured out and where i am stuck and need some help.


in themes/nu-themes there are a bunch of |theme_name|.nu files.

preview-generate-screenshots.nu

globs all of the files in this folder, getting the theme name with path parse | get stem.

so for instance the theme themes/nu-themes/gruvbox.nu the $theme_name is gruvbox

every theme that you want to add should go in themes/nu-themes otherwise the script will not see them and generate stuff for you.

load this file with use ../nu-themes/gruvbox.nu *

this file is an export def main that is called with gruvbox and returns an object with keys and values. some of those values are used to configure the theme colors when taking a screenshot it looks like.

the script gets foreground and background keys, and mashes them together with sgr_colors using .... $agg_theme uses this to convert a screen recording to a gif.

in this example, the value gruvbox is passed in for $theme_name

on the command line, both

use themes/nu-themes.gruvbox.nu *
gruvbox | get foreground

or

use themes/nu-themes.gruvbox.nu *
(gruvbox).foreground

work.

the main sript gets passed in the screen_capture_method and then calls save_screenshot screenshot_capture_method $theme_name

for every .nu file in themes/nu-themes

after the file is loaded, you should be able to do

let command = "gruvbox | get foreground"
nu -c $command

but you cant!

in the script you have to load this theme with

use $"../nu-themes/($theme_name).nu"

but obviously the compiler throws an error for $theme_name here, saying "not a parse-time constant".
it is not a constant to be fair, so it is not wrong but it is annoying, i just want to load this file, i know it is there, i just need the compiler to know it is there!

i thought i could get around it by passing save_screenshot an extra parameter that is a list of all the $theme_name's that are in nu-themes

and it gets me a bit closer but the nu -c $command errors out with gruvbox is not found

"
gruvbox is neither a Nushell built-in or a known external command
"

this error is probably why the script feels so magicky with the string escaping going on. how else would you go about hot loading everything?

feel like this might be an export def main quirk,
because i can call all of my other definitions that are not export def main's this way.

assuming you can get those errors to go away, and you can call the command with nu -c,
this script will be way easier to understand and follow

so for questions,

how would you go about getting around the "not a parse time constant" and how would you tackle not being able to run nu -c $theme_name when you can run the command on the command line?

this might be why the script has alot of string escaping going on. this has been something that i wanted to try to fix. at the very least i would gain some knowledge about nushell i did not already know.

maybe i am missing really easy, but this is the point where i can not go any further.

if i can get some help with that i can finish the rest of this pr

i had an idea for the asciinema, powershell, and minicap scripts. they are just template files and you substitute the theme_name for the placeholder and it works, but then you get these other errors.

@fdncred fdncred marked this pull request as draft September 11, 2025 11:26
Copy link
Contributor

@fdncred fdncred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for trying to help. I probably won't be accepting this PR because you've moved the catppuccin themes. They're in the custom folder because they're not included in the source repo of the original themes.

No offence, but there are too many words in your description for me to understand what you're wanting/trying to do.

@scubacabra
Copy link
Contributor Author

no offense taken. this was definitely something i was going to clean up. thanks for patience.

re: catppuccin
i finally got the script to run, the lsp helped with alot of the errors. some variables had typos and it was loading the wrong thing from the std-lib-candidate-archive

i fixed it and everything ran through, but none of the themes in nu-custom-nu-themes were included in the output files for screenshots.

none of those screenshots are going to show up here

https://github.com/nushell/nu_scripts/blob/main/themes/screenshots/README.md

the preview script only looks in the nu-themes folder for themes to screenshot

anything in the custom-nu-themes folder won't ever get seen by the preview script.

i assumed that you might want to take screenshots of all the themes, so i moved the catppuccin-themes over. i did forget about the other themes there, but this is just a draft. i can take the catppuccin themes off if you want. now that they are in nu-themes those themes show up and are screenshotted. for every file in nu-themes the script calls (for example)
file: nu-themes/darcula.nu save_screenshot "darcula". it does that for all the modules in that folder. if the module is not in that folder it will not be screenshotted.

it's not pressing, i am not going to do it all tomorrow, but do you mind if i work through some of the issues i am coming across here? i am kind of close, i think it is kind of neat, but i might need some nushell help on a thing or two (not like i can just eval whatever i want). definitely messy in my head but trying to clean it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants