Commit Graph

1024 Commits

Author SHA1 Message Date
Auca Coyan
0cba7933f2
add worktree completions (#933)
you can now `git worktree remove <tab>` for autocompletions

![image](https://github.com/user-attachments/assets/2eac159c-fd86-42c4-9ecc-469b333dea52)

and show the branches _after_ the path in `git worktree add ./my-path
<tab>`

![image](https://github.com/user-attachments/assets/d5fadce3-8153-4d51-82e3-0a911ecdefb6)
2024-08-14 15:40:59 -05:00
Kira
7b2ec35cf2
Update scoop completions (#930)
made scoop completions a bit more reliable by converting the PsObject
from powershell to json instead of parsing lines from the `scoop help`
output

doesn't take any longer since scoop run in powershell either way

Co-authored-by: unknown <67888720+kira-nyx@users.noreply.github.com>
2024-08-14 06:16:37 -05:00
Christoph Blessing
1b5584a71d
Fix network option missing type (#929) 2024-08-12 12:00:26 -05:00
David
e0ccb8fecc
Add ttyper completions (#928)
Added ttyper completions. Ttyper is a little tool for speed typists
(readme included).
2024-08-10 15:31:02 -05:00
David
135373dc28
Add croc completions (#927)
Adds croc completions. Readme about tool included.
2024-08-10 15:30:38 -05:00
Jonas
e4d721e08b
Top commands one-liner (#926)
This pull request adds a script containing a one-liner that can be used
to get a table containing the top 5 used commands by using the history
file
2024-08-09 08:05:41 -05:00
Devyn Cairns
5eb484f986
Add warning to release checklist for nu-ansi-term (#912)
@fdncred said that it's quite tricky to release `nu-ansi-term`, so we
probably shouldn't generally do it during a nushell release
2024-08-06 14:16:48 +02:00
NotTheDr01ds
9a12d8df39
Additional Theme Features (#925)
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.
2024-07-29 17:08:13 -05:00
Devyn Cairns
6d6a157600
Add recursive fibonacci benchmark (#924)
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.
2024-07-28 07:15:55 -05:00
OJarrisonn_
54546c8bf2
Refactor of docker completions (#922)
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
2024-07-27 15:55:40 -05:00
OJarrisonn_
0b487e8380
fix: use proper path type for path argument for bat (#921)
Use of `string` disable `~` expansion

Signed-off-by: OJarrisonn <j.h.m.t.v.10@gmail.com>
2024-07-27 14:05:48 -05:00
OJarrisonn_
6bbd75120d
fix: use proper path type for path argument for eza (#920)
Using `string` may disable `~` expansion in modern nushell (>= 0.95)

Signed-off-by: OJarrisonn <j.h.m.t.v.10@gmail.com>
2024-07-27 14:05:22 -05:00
NotTheDr01ds
60b1444742
Update themes preview to use chunks in place of deprecated group (#918)
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).
2024-07-25 10:42:06 -05:00
Christoph Blessing
2321b5b29a
Fix incorrect docker commands (#917)
Fix "docker run" and "docker container run" custom commands incorrectly
expecting a "network" positional argument.
2024-07-25 10:40:50 -05:00
Darren Schroeder
891854f25f
Create image-actions.yml 2024-07-25 08:20:20 -05:00
Jack Wright
6b962c8f46
Fixing ordering / added nu-drive-value for nu_release.nu (#915) 2024-07-24 10:07:58 -05:00
Elizabeth
eedcd10dbb
Fixed sys usage (#916)
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
2024-07-24 09:09:31 -05:00
Devyn Cairns
3b39ef75c9
Add more notes about transferring ownership during release (#914)
Try to avoid delayed releases by mentioning it several times, haha
2024-07-24 02:49:39 +00:00
Devyn Cairns
6eb1398f4e
Move notes for plugin developers to top level in release notes (#913)
The changes noted here aren't always breaking changes, so it makes sense
to just have them at top level. I also fixed the missing TOC link.
2024-07-24 02:26:12 +00:00
NotTheDr01ds
90bab5a139
Fix cell-path in themes (#911)
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`
2024-07-22 15:52:01 -05:00
Antoine Stevan
ecfbad67b9
work on the nu-themes make script (#905)
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 😉
2024-07-22 14:55:32 -05:00
NotTheDr01ds
995c1ea21c
Update theme preview scripts and screenshots (#909)
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"
2024-07-22 14:21:28 -05:00
sadguitarius
770dfe6d4e
add silent option to nu_msvs (#910)
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.
2024-07-22 14:08:46 -05:00
Auca Coyan
d64004f710
Fixes scope commands call and columns (#908)
Hi! Just to more fixes in the queue 😄
2024-07-21 07:40:22 -05:00
Auca Coyan
ba46538785
🐛 parser fixes (#801)
- replace `str collect` for `str join`
- replace `str lpad` for `fill`
- `str lpad -c` for `fill --width`
- `str rpad -l` for `fill --alignment r --width`
- updated `before_v0.60/README.md`
- `$nu.scope.commands` for `scope commands`
- add a couple of `if (true) {} else {}` (else keyword)
- `$true` for `true`
- `$false` for `false`
2024-07-21 07:21:21 -05:00
OJarrisonn_
be32cdaefc
fix: catppuccin themes declared a const inside a record (#907) 2024-07-21 07:00:51 -05:00
Antoine Stevan
59171b0fd9
bump the nu-hooks package to 0.2.0 (#901)
as per title

## changelog
- "did you mean" improved in #811
- "nuenv" added in #889
- "startup times" added in #888
- "tookit" added in #888
2024-07-21 07:00:02 -05:00
Okdro
0906f7a15c
Feature/add git grep completions (#898)
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.
2024-07-21 06:59:39 -05:00
Antoine Stevan
71f5736d93
RFC: add a command to help parsing arguments in scripts (#875)
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>
2024-07-21 06:58:34 -05:00
Antoine Stevan
6aa2700730
add ways-to-add-up-to to "math" module (#874)
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
2024-07-21 06:55:45 -05:00
OJarrisonn_
8d8a865b38
fix: nu-complete for git ref and git files-and-ref uses nu-complete git switch now (#906)
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)
2024-07-21 06:35:26 -05:00
NotTheDr01ds
5a73ddfa18
Bump stdlib-candidate nupm version (#904)
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.
2024-07-19 17:11:29 -05:00
NotTheDr01ds
8bf899c6c2
Remove multi-line flag from regexes (#903)
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.
2024-07-19 16:15:58 -05:00
NotTheDr01ds
8557653047
Recover non-lemnos themes (#902)
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.
2024-07-19 13:27:05 -05:00
NotTheDr01ds
bd1ab4e7a7
Simplify theme usage (#896)
* 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`
2024-07-18 15:39:46 -05:00
NotTheDr01ds
ca309b988e
New std-rfc command str dedent (a.k.a. unindent) to remove common indentation from a multiline string (#894)
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.
2024-07-16 12:20:18 -05:00
Okdro
7471b4d966
Added Git completions for the restore subcommand (#895)
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.
2024-07-16 12:20:00 -05:00
denny
1533149826
Fix: SSH config may not contain hostname (#893)
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.
2024-07-11 10:26:04 -05:00
Devyn Cairns
0d70dbddd5
Add fibonacci benchmark, for fairly low-level eval performance (#892)
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`.
2024-07-11 06:03:36 -05:00
denny
bfd2af7106
Add ssh completion (#891)
Read ssh config from `/etc/ssh/ssh_config` and `~/.ssh/config`.

Given: 
![螢幕擷取畫面 2024-07-09
232722](https://github.com/nushell/nu_scripts/assets/5771562/9294efd7-42c0-4a6c-9dac-06a6a87f67c5)

Will show:

![螢幕擷取畫面 2024-07-09
232640](https://github.com/nushell/nu_scripts/assets/5771562/a8e3844b-ac91-417b-a973-c31366ae1460)
2024-07-10 08:26:11 -05:00
Antoine Stevan
d6cf03e315
add "nuenv" hook (#889)
> 💡 **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)
```
2024-07-03 22:06:54 +02:00
Antoine Stevan
1fb482ec31
add "toolkit" and "startup times" hooks (#888)
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
😇
2024-07-03 22:05:52 +02:00
1adept
1f3dc8b98d
just-completion: "export def" -> "export extern" (#860)
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.
2024-07-02 20:55:31 +03:00
Schweber
61a805eb06
nix/activation-script: update for nushell 0.95 (#890)
- remove `str trim -l -c '+' |` as it's no longer needed with nushell
0.95
- Change display of total size difference
2024-06-29 15:59:53 -05:00
Jack Wright
cde54b2876
Prevent branch from merging against main (#886)
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
```
2024-06-26 06:34:03 -05:00
Ian Manske
e5388d1992
Edit release notes template (#887) 2024-06-26 02:12:36 +00:00
Jakub Žádník
b1cd222c2a
Fix error when listing PRs by milestone (#885) 2024-06-25 21:25:42 +03:00
Kuo-tung Kao
526c9525ea
fix ka command in kubernetes module (#884)
substring ..-1 not working. Use str trim to remove '-'
2024-06-24 07:00:35 -05:00
Bruce Weirdan
a992f5b4fa
Add jc wrapper (#883)
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
2024-06-22 12:41:11 -05:00
Darren Schroeder
92db3a88eb
update vswhere location for nu_msvs (#882)
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.
2024-06-18 09:19:02 -05:00