Changes to `make.nu`:
* Adds in missing shapes and types noted further down in this PR by
@fdncred
* Adds colors for types - Mostly matching the corresponding shape, but
with any attribute (e.g., bold) removed
* Changed `int` and `float` values to be distinct. In most themes, the
colors should be complementary.
* Changes `bool: false` and `hints` colors - They were hardcoded to
`dark_grey` and wouldn't show up on some themes. Now uses a theme color
that should correspond to a theme-appropriate grey in most cases.
* Alphabetizes shapes and types so that Previews are also sorted
properly
* Eliminated spurious newline when sourcing theme (from printing OSC
codes for terminal colors)
* Renamed `3024` theme to `3024r` since module names can't be an `int`
Changes to `theme preview small`:
* Remove extra vertical spacing that was caused by different-sized row
column content
* Logically group elements - Types, Conditionally computed (closures)
types, Shapes, and other Structure (e.g., header, row_index, foreground,
etc.)
* Displays foreground/background on one line for clarity
Result is a much more compact, but also more readable, table.
Comparison:
<details><summary>Before</summary>
<p>
<img
src="https://github.com/user-attachments/assets/2673855d-d20d-4e14-8029-255138f2ecc9"
/>
</p>
</details>
<details><summary>After</summary>
<p>
<img
src="https://github.com/user-attachments/assets/c8824b7a-440d-4567-bd69-b2e1df358340"
/>
</p>
</details>
* Also refactored a lot of the code to be more maintainable - Moves the
rendering off to separate functions.
Changes to `preview_generate_screenshots.nu`:
* Accepts the method for generating screenshots as an argument
* Additional generation method using asciinema, agg (asciinema to
animated gif), and ffmpeg (to convert the animated gif to a single-image
PNG)
Additional Notes:
- Some Lemnos themes use color values that are the same (or nearly the
same) as the background in places. These are "broken" themes and always
have been as some elements will simply not be visible.
- There's a longstanding (I believe) bug that special-cased `record` for
the *key* rather than the *value*. I've fixed it so that the *key* is
now handled properly (same as other types), but I haven't implemented
any changes for color values that use a record (e.g., `{ fg: "#80a1a1",
attr: "b" }`) as this would make the table less compact. I'll look at
doing this for the longer form `preview theme` later.
- Closures other than for `string`, `bool`, `date`, and `filesize` are
currently only displayed as a summary. There aren't any themes currently
that this impacts, but if you create one manually, the display results
were pretty bad. This is primarily due to bad indentation from
`config.nu` (and/or defaults). A proper `nu-indent` would help fix this,
or maybe we could just remove all whitespace and display any closure as
a one-liner.
I probably won't regenerate screenshots until we figure out what to do
about the "monotone" type colors.
This is pretty much the least efficient reasonably simple way to
implement fibonacci in Nushell, and it's a good benchmark to profile our
custom command call performance, as this is the majority of the work
being done.
I think it may actually be good to add this and the other one to `cargo
bench` so we can track it over time, but it's also useful as a script so
it can easily be profiled.
Refactor docker custom completions to reorder `export extern`
declarations and make use of `export alias` to avoid repetition
Also fixes `docker run` needing a mandatory `network` argument which
doesn't exist
Also `print`s the theme rather than just returns it from `preview theme
small` - Otherwise we can't "script" the theme preview as part of
screenshotting (found while recording with Asciinema).
Just as a heads up, I haven't really tested this since a lot of it is
stuff I don't use or know how to set up without some reading up. I have
tested the nu_conda_2 change since I have a python project that I use
that for, and I could look into testing more of it if needed.
I've tried finding (naively using `/sys\W/`) all the usage of the old
plain `sys` calls and replacing them with alternates as appropriate,
which mostly has been to swap a `(sys).host.name` call into a
`$nu.os-info.name` one, since it'll be tad faster and more consistent
across platforms with naming (especially as the value comes from the
[rust stdlib](https://doc.rust-lang.org/std/env/consts/constant.OS.html)
and is very predictable).
Fixes#897
Four minor changes:
* As previously mentioned, updates `make.nu` to use `cell-path` rather
than `cellpath`
* Slight improvements on #905 (cc @amtoine) - The last theme converted
was the only one printed via `info`, but it didn't get removed from the
screen. Things moved so fast on my system that it looked like only one
theme was being converted, since that's the only message that was left
on the screen ;-). Now prints a "Done" message showing how many themes
were converted and how many failed.
* There was a previous update to `catppuccin-latte.nu` that was
apparently made directly to the theme, rather than the custom src.
Synced these up.
* Bumped `nupm.nuon`
i was mostly having fun there 😋
cc/ @NotTheDr01ds
## changes
- using some colors for the logging
- slight refactor of the main, i.e. i build a `table<name: string,
source: string>` of themes and then iterate over it and call `make-theme
$t.name $t.source`, thus getting rid of the twin pipelines
- i also build a `table<name: string, source: string>` of failing
themes, to show them at the end
## reviewing
i think the best to review this is
- go to `themes/`
- remove any copy of the `lemnos/` directory
- run `./src/make.nu` twice and see the output 😉
Lots of changes - Pretty every change needed to be made before updating
the preview screenshots, so they all end up in the same PR here:
* `preview-generate-screenshots.nu` now generates the previews and
screenshots all in one pass rather than requiring a separate file.
* Adds a new method for generating screenshots using PowerShell with no
third-party application required. Created new function for choosing the
method that is used to generate screenshots.
* Fixes background color on `nushell-dark` and `nushell-light` themes.
* Fixes bug where `cursor` setting (and perhaps one other) was getting
dropped from the preview table (`math ceil` was needed rather than `math
floor`)
* Fixes `cellpath` setting - Was changed to `cell-path` a while back but
never updated in the themes. All themes and their previews were
regenerated. Custom themes were manually adjusted.
* **Important:** I did not update `make.nu` to fix this (yet) since
@amtoine has a open PR against it that has not been merged yet. Easier
to either put that change in that PR or do it after that one has been
merged.
* Adds `mod.nu` in the root of the `themes` module. Moves some of the
previous script commands such as `preview_terminal`,
`preview_theme_small`, etc. over to the module. Makes for cleaner usage.
* Note: The completion functions in the scripts have been broken for
several months. I did not fix this at this point.
* `preview_theme_small` (and others) renamed to use spaces in command
name, so it is now `preview theme small`.
* Fixes bug of my own making that prevented several custom themes from
working.
* Refactors the "list to columns" code to use `group` (will need to be
updated to `chunks` in 0.96)
* Suppresses the indices column in the preview table
* Removes the column headers entirely since they don't serve any purpose
in this type of "columnar table"
I like to activate nu_msvs in my config by default and don't need a
message that tells me the command has been run when doing this. This
commit adds a --silent option so there's no message displayed when
running the command.
Added completions for most of the flags for `git grep`.
A few flags have been omitted for this PR due to Git expecting arguments
for those be passed without whitespaces. The arguments are optional, but
the flags would not work when passed arguments (see `--open-with-pager`
and `--color` flags in [this
commit](ffa9ceab73)
for how I tried to do it).
Ex.
`--open-with-pager(-O)` expects the optional argument to be passed as
either `--open-with-pager=<pager>` or `-O<pager>`. Including it in the
completions list as I had implemented it breaks the flag when using the
optional parameter.
Feedback appreciated for how to handle that. I'm still new to the Nu
language, so I might have missed something obvious that could fix that.
the other day, i was writing a script and wanted to pass a `list<int>`
to it which is not possible because there is no such things as _types_
for externals 🤔
i ended up writing an "arg parsing" command to help in that task and
thought it could be useful to people 😇
in this MR, i add `std-rfc parse-arg` in the `script-parsing.nu` module
and add associated tests which all pass.
i invite the reader to have a look at the docstring of `parse-arg` which
should contain a full example explaining the usage of this new command
😉
---------
Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
at my job, i studied very quickly something that involved computing all
the ways one can build a positive integer from the addition of other
positive integers.
enters the `ways-to-add-up-to` command i've written and added to the
`math` module in this PR.
## example
`ways-to-add-up-to 4` will be `[[1, 1, 1, 1], [1, 1, 2], [1, 3], [2, 2],
[4]]]` because $4$
can be obtained as follows:
$$ 1 + 1 + 1 + 1 $$
$$ 1 + 1 + 2 = 1 + 2 + 1 = 2 + 1 + 1 $$
$$ 1 + 3 = 3 + 1 $$
$$ 2 + 2 $$
$$ 4 $$
> **Note**
> $1 + 1 + 2$ and $1 + 2 + 1$ are considered the same because addition
is _commutative_ and thus only `[1, 1, 2]` will be returned
Git `nu-complete` defs where outdated, using a removed function
`nu-complete git switachable branches`, now using `nu-complete git
switch`
Already tested (except for tags)
Forgot to bump the Nupm version, but then again everyone else did as
well ;-)
Updated it to 0.3.0 (skipped 0.2.0) since it looks like there have been
two commands that have been either added or drastically changed since
0.1.0.
Minor fix on `str dedent` - I erroneously used the regex multi-line flag
`(?m)` in several patterns where it shouldn't have been. For the most
part, this was harmless, but it did surface an error when I was working
on updating the themes.
Fixed these and added two new tests that would have caught the issue.
Changes:
* Custom Nushell `color_config`'s (non-Lemnos) are moved to the
`./src/custom-nu-themes` directory and used to generate the main theme
files when doing a `./make.nu`
* `make.nu` and other scripts (e.g. preview) have been moved to the
`src` directory
* A separate `README` for the `src` scripts
* Main theme `README` updated for clarity
* Reordered the theme template, so all themes were regenerated. I'd like
to stop doing this ;-)
@amtoine Thanks for your suggestions on the `README`. I've pretty
extensively changed the flow, so please re-review and let me know how it
looks. Also note that I haven't personally tested with Nupm, so please
especially review this section. Thanks!
@fdncred CC
Still planning on working on the preview scripts next. They'll need only
slight changes to run (probably a path change), but they can be
simplified a bit now, I hope. At the same time, I'll complicate them in
other ways ;-).
Note that there is a bug in both `nushell-dark` and `nushell-light` that
prevented the terminal colors from being updated regardless. You can see
that in the existing screenshots, where both those themes simply re-use
the previous theme (alphabetically's) background. I haven't fixed this
yet.
* Primary change: Simplifies theme usage by adding an `export-env` to
each theme so that `$env.config.color_config` is automatically set when
importing the module.
Rather than the old:
```nu
use nu-themes/nushell-dark.nu
$env.config.color_config = (nushell-dark)
```
It's now a single-step:
```nu
use nu-themes/nushell-dark.nu
```
* Updates `make.nu` to create the theme files (uses the previously added
`str dedent` for clean output).
* A couple (literally, 2) of the remote themes did not have all
necessary colors and failed. Updated `make.nu` to continue on error, but
report the failures.
* Updated `README.md`
Finally got around to polishing up and contributing the concept from
[Nushell #11477](https://github.com/nushell/nushell/issues/11477).
This is based on a (very slightly) modified version of the [Swift
approach](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/stringsandcharacters/#Multiline-String-Literals)
suggested by @jameschensmith:
<img
src="https://docs.swift.org/swift-book/images/org.swift.tspl/multilineStringWhitespace~dark@2x.png"
width="480" />
```nu
> use std-rfc str
> let s = "
Totally unindented
Indented by two spaces
Indented by four spaces
Intended by two spaces
Unindented
"
> $s | str dedent
Totally unindented
Indented by two spaces
Indented by four spaces
Intended by two spaces
Unindented
```
Specifically:
* Requires a multi-line string where the first and last lines are blank
(empty or contains only whitespace)
* Will error if the first and/or last line are not blank
* The amount of indentation to remove is based solely on the *number of
spaces* on the final line of the string
* Tabs are not considered for indentation calculations
* The first and last line of the original string are not returned as
part of the dedented string. Those lines are for "control"/formatting
purposes only.
* If you want the string to end in a linebreak, simply add an extra
blank line before the last "control" line (as in the example above).
* Unlike the Swift format, whitespace is allowed on the first line of
the string. It may not be visible to the user in their IDE, and there's
just no reason to create an error in this case since the line is
intended to be stripped anyway.
* *Only* indentation whitespace is removed. Any other whitespace is left
untouched, including that on otherwise empty lines.
A good (I hope) set of examples for these rules can be found in the test
cases.
Added `git restore` to git completions, as I was missing tab completion
for that.
I've begun to use Nushell regularly, so I hope this addition will be
useful to others as it is to me.
Feedback is appreciated if there's any conventions I've missed, or
options that need better wording.
I am sorry. I assumed that an SSH host in the config file must contain a
hostname, but this assumption is not true.
If a user reads an SSH host that doesn't contain a hostname, it will
fail to parse.
This is a benchmark that I created while testing IR. It's meant to
basically do only very simple operations but be running 100% Nushell
code most of the time, without any heavy lifting being done by commands,
and without any closure calls or anything like that. It seemed useful to
keep around so I'm adding it to `nu_scripts`.
> 💡 **Note**
>
> greatly inspired by _Direnv_
this new "_nuenv_" hook will `source` any `.env.nu` file found in the
current directory as part of a hook.
in order to be a bit more safe, i've added `nuenv allow` and `nuenv
disallow` that will keep track of which "env" files are allowed to be
sourced, i.e. if a file is not allowed, then you'll have to run `nuenv
allow` first.
## example usage
```nushell
use nu-hooks/nuenv/hook.nu [ "nuenv allow", "nuenv disallow" ]
$env.config.hooks.env_change.PWD = (use nu-hooks/nuenv/hook.nu; hook setup)
```
i wanted to share some of my hooks, as i don't see equivalent things in
the `nu-hooks` package 😌
## new hooks
- `toolkit.nu`: creates a hook that will activate any `toolkit.nu`
- `startup-times.nu`: creates a hook that will log the startup times in
a log file
## review
i think the easiest is to read the docstring and arguments of the two
`setup` commands i've added in the two modules defined above 😉
cc @fdncred, i might have missed the latest and hotest features of the
"startup times" hook, please tell me if something should be added
😇
Changing "export def" to "export extern" to not shadow the original
command as it would disallow anything not defined in the re-definition
There seem to be similar cases in completions for (naive search with "rg
'export def'")
- mask
- winget (exports some defs and some externs. So i dont know if those
defs are actually additional functionality)
- pnpm (only exports some 'nu-complete' defs)
- pass (only exports some 'nu-complete' defs)
I don't feel comfortable changing those as i am not familiar with them.
Having the the main branch listed in the checkout command:
```nushell
git -C $repo checkout -b $branch nushell/main
```
Made my git to track against the main branch, causing it to push to main
instead of a branch. Removing the branch fixed the problem:
```nushell
git -C $repo checkout -b $branch
```
This PR adds `jc` wrapper, so that `jc` output is automatically parsed
into a nushell data structure and you don't have to use `| from json`
filter to parse it.
References: https://kellyjonbrazil.github.io/jc/#jc
This PR makes the location of vswhere more programmatic by looking where
it's supposed to be located on the file system instead of relying on it
being in your path.
I changed `export-env {}` at the beginning to a custom command to avoid
having `export-env` run when loading the module
because:
1. I couldn't use `nu_msvs activate` because it depends on env vars
being set that were hidden with `nu_msvs deactivate`
2. It seems that `export-env` executed at `use`, leaves `$env.FILE_PWD`
available in the environment which I think may be
a bug. So, putting it in a custom command avoids that.
This updates the nu_msvs module. There were several things that I didn't
think looked proper for Windows so I changed them an hopefully made this
module a tiny bit better.
[`kw`](https://github.com/kworkflow/kworkflow) is a tool used by kernel
developers to help with the workflow
---------
Co-authored-by: Lais_Nuto_Rossman <laisnuto@gmail.com>