Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
isgruvbox
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 withgruvbox
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
andbackground
keys, and mashes them together withsgr_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
or
work.
the main sript gets passed in the
screen_capture_method
and then callssave_screenshot screenshot_capture_method $theme_name
for every
.nu
file inthemes/nu-themes
after the file is loaded, you should be able to do
but you cant!
in the script you have to load this theme with
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 innu-themes
and it gets me a bit closer but the
nu -c $command
errors out withgruvbox
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.