Commit Graph

984 Commits

Author SHA1 Message Date
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
Darren Schroeder
ddbebf197d
add find_msvs custom command to the nu_msvs module (#881)
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.
2024-06-18 08:09:04 -05:00
Ian Manske
92f20ff282
Rmove usage of deprecated str contains --not (#880)
Related: https://github.com/nushell/nushell/issues/13163
2024-06-16 17:30:53 -05:00
Darren Schroeder
9b08b15981
update nu_msvs module (#879)
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.
2024-06-13 14:45:43 -05:00
laisnuto
c0b4853f5d
fix alert in kw completions (#878)
We update the code to add the alert function in the --alert subcommands
2024-06-13 09:13:24 -05:00
OJarrisonn_
5cc4e991ab
feat: added completions for kw (#877)
[`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>
2024-06-13 08:43:18 -05:00
Maxim Uvarov
398cc82308
std bench improvement proposal (#873)
- removed usage of a new external command `math significant-digits`
- rounded precision to 4th digit including (max relative error of 0.05%)
- in `--pretty` I replaced abs `stddev` with relative `coefficient of
variation` (CV)

@amtoine, would you please take a look into my new variant once again? 
Maybe this time it will be good enough? 

<img width="804" alt="image"
src="https://github.com/nushell/nu_scripts/assets/4896754/49e62609-4301-4d5c-b1f5-d2c3355cb33e">
2024-06-08 09:31:29 -05:00
neur1n
d95857c119
resolve several issues in nu_conda and nu_msvs (#872)
1. fix: update `(sys).host` to `sys host` to work for 0.94.x
2. fix: handle incorrect behaviors when re-importing nu_conda or nu_msvs
3. doc: update minimum requirements of nushell in README.md
2024-06-07 07:36:00 -05:00
OJarrisonn_
de2829091f
feat: updated rustup completions to use the new rustup help page style (#871)
Rustup help page changed, so the commands that were based on the old
layout to get the completions were broken

Improved some completions to include a description like "default" or
"installed"

Also added completions for `rustup help`
2024-06-06 07:41:15 -05:00
OJarrisonn_
3bceafd6da
feat: add eza completions (#870)
Adds completions for the eza tool
2024-06-06 07:28:29 -05:00
Darren Schroeder
a1c3ace432
Revert "Revert "Add git coommit completions"" (#869)
Reverts nushell/nu_scripts#868

I found that this works, if you source these files like
```
use aliases/git/git-aliases.nu *
use custom-completions/git/git-completions.nu *
```
but if you source them like this, it doesn't work.
```
use custom-completions/git/git-completions.nu *
use aliases/git/git-aliases.nu *
```

This changed recently somewhere in nushell.
2024-06-05 07:41:42 -05:00
Darren Schroeder
5adf14dab9
Revert "Add git coommit completions" (#868)
Reverts nushell/nu_scripts#854

This PR broke the git aliases
https://github.com/nushell/nu_scripts/blob/main/aliases/git/git-aliases.nu
so I'm reverting it.
2024-06-05 07:21:14 -05:00
Thiago Duvanel
8a91aa8bf4
Added docker completions (#867)
This script provides completions for the docker command. It is based on
the official docker documentation.
2024-06-04 19:52:49 -05:00
laisnuto
95670ddfcb
Complete git pull (#866)
Create compleations for git pull
2024-06-04 19:47:38 -05:00
Maxim Uvarov
308d858c4f
simplify the std bench improvement candidate (#865)
@amtoine gave me valuable feedback about the [PR of `std bench`
improvement](https://github.com/nushell/nu_scripts/pull/859) CANDIDATE
into `stdlib-candidates`.

I understood and respected his reasoning about his position. Yet, I
still believe that users of `std bench` will benefit from my proposal.

I incorporated some of @amtoine advice in this PR.

I removed the `bench --units` option as I now believe it is better to
encourage users to use core functionality for formatting duration (which
I had not thought of initially) and to avoid multiplying `--options`.

```
bench -n 10 {sleep 0.1sec} | format duration ms mean min max stddev
# or
bench -n 10 {sleep 0.1sec} | format duration ms ...($in | columns)
```

Also, I removed the option of `--sign-digits` and just hard-coded the
precision of conversion to the fourth significant digit (which will give
a maximum relative error of 0.05%, which I still think is unnecessarily
precise).

To explain my motivation, I added some context from our previous
conversation:

>> Maybe you would agree with me that this representation is very wordy
and unnecessary, even for a professional?
>> `1sec 333ms 333µs 333ns`

> maybe, but then i would argue the issue comes from the formatting
nushell does on durations, not from std bench, it's just that Nushell
will show every part of the duration 😕

And I add here that if Nushell adds the setting for resetting
insignificant digits from displaying, those conversions could be removed
for the better. Yet, we don't have such a setting yet, but we already
use bench and use it quite often. So, I propose this usability
improvement.

In my defense, I would add that the existing `--pretty` option will only
benefit from the proposed changes (while it can't benefit from `| format
duration ms`).

```diff
> bench {sleep (10sec / 3)} --rounds 2 --pretty
- 3sec 335ms 974µs 264ns +/- 1ms 108µs 748ns
+ 3sec 335ms +/- 1ms 108µs
```

Finally, I kept the `--list-timings` option because I strongly believe
that users much more often will not need expanded 50 lines of timing
results on their screen (which they can get rid of by adding `| reject
time` in the second execution of the `bench` command - but I would like
to avoid this second execution).

I won't be hurt if my proposed changes aren't accepted and applied to
mainstream. Yet, I feel like my initial PR is still valuable and will
benefit from my current PR's additions.
2024-06-03 08:35:33 -05:00
Maxim Uvarov
f41d050d32
hotfix for significant-digits to not error if the input was 0 (#863)
In the last `pr` there was an error, that I just discovered and fixed.
Also I added test for this case in future, and some test for negative
numbers

```
0 | signfificant digits 2
 33 │
 34 │     let insignif_position = $n - 1 - ($num | math abs | math log 10 | math floor)
    ·                                       ──┬─              ────┬───
    ·                                         │                   ╰── 'math log' undefined for values outside the open interval (0, Inf).
    ·                                         ╰── value originates from here
 35 │
    ╰────
```

I'm sorry for hassle here 😞
2024-06-03 08:33:34 -05:00
Maxim Uvarov
ae5c1a2727
update significant-digits to not use string conversions (#862)
Thanks to kfarmer (a
[conversation](https://discord.com/channels/601130461678272522/615253963645911060/1247031648965492766)
on discord) for proposing his version and motivating me for this update
2024-06-03 07:06:51 -05:00
zhangym
1dbc16cfb7
feat: add docker aliases (#861) 2024-06-03 06:38:38 -05:00
Maxim Uvarov
5271d68b7a
improve std bench and add significant-digits (#859)
Hi! I propose several changes to `std bench`:
- Remove insignificant precision by default (can be reverted with
`--sign-digits=0`).
- Remove the 'times' field by default (can be returned with
`--list-timings`).
- Add an option to set time units (inactive by default).

For removing insignificant precision, I needed a new command
`significant-digits` which is also included in this PR. This command has
tests.

<img width="747" alt="image"
src="https://github.com/nushell/nu_scripts/assets/4896754/ce98aebe-7c1b-4d8f-b2d0-3282d1ff3883">
<img width="747" alt="image"
src="https://github.com/nushell/nu_scripts/assets/4896754/508fef3e-ba70-40fd-8f9e-82b6ac608485">
<img width="747" alt="image"
src="https://github.com/nushell/nu_scripts/assets/4896754/af755f28-8506-4f4c-8bc2-91b35798855d">
2024-06-01 04:54:45 -05:00
Darren Schroeder
a921551619
features = full isn't a thing anymore 2024-06-01 04:41:31 -05:00
David Danier
e4dbec663b
Support whitespace before target name for make completions (#858)
TL;DR: The "simple" example from
https://www.gnu.org/software/make/manual/html_node/Simple-Makefile.html
is currently not compatible with the custom completion script found in
`custom-completions/make/make-completions.nu`. This PR tries to fix
that.

As I was working on `nur` (https://github.com/ddanier/nur) and the
`nurify` script to convert to `nur` from different task runners
(https://github.com/ddanier/nur/blob/main/scripts/nurify.nu) I wanted to
create a good way to convert from using `make`. So I thought the `make`
completion would for sure implement a good way to get a list of all
possible `make` targets. Hence I started looking at
`custom-completions/make/make-completions.nu`.

Then I searched for a good documentation for how `Makefile`s work, as
the last time I was using this myself is about 5 to 10 years ago. If you
for example look at the documentation on gnu.org you may find examples
of `Makefile`s not working with the current autocompletion. See
https://www.gnu.org/software/make/manual/html_node/Simple-Makefile.html
for example, the "simple" example they provide.

The reason for this not working is that the targets use some whitespace
after the target name. This is somehow allowed and thus valid. See
https://www.gnu.org/software/make/manual/html_node/Rule-Introduction.html
for a quick overview about how the `Makefile`s syntax works. I quickly
checked this to ensure `make` actually parses this correctly, it really
does.

This means that the current `make` completion does miss support for the
"simple" example provided my `make` itself. So I went on to fix this.

My suggested solution is:
* Filter all lines by regex `'^[\w\.-]+\s*:'` to ensure possible targets
  - start with some word (also allowing `.` and `-`)
  - may have some whitespaces after the word
  - has ":" after this
* Split by the ":"
* Use first column
* Trim the remaining target name to remove those nasty whitespaces
* Use result for completion

For me this did fix the issue with the "simple" `Makefile`, allowing me
to put this into my `nurify` script.

Would be nice to get this "backported" to nu scripts as well. Might help
others 😉
2024-05-30 14:37:43 -05:00
Ian Manske
85205b0e66
Edit release notes template (#853)
- Removes the note about installing the dataframes feature.
- Moves the command changes section to the top level, renames some sub
sections, and adds some more sub sections.
- Moves and simplifies the hall of fame.
2024-05-28 19:32:39 +00:00
Ian Manske
c133ab2419
Remove nu-cmd-dataframe from release script (#857) 2024-05-28 13:07:59 +00:00
OJarrisonn_
f6ec482ea3
feat: git clone completions (#856)
Adds completions for the `git clone` command
2024-05-28 06:35:27 -05:00
OJarrisonn_
edb832840f
feat: add ./gradlew completions (#855)
Adds completions for when using a `./gradlew` script in Gradle projects

The script provides completions both for the script flags and for the
available tasks in the current project
2024-05-28 06:34:50 -05:00
laisnuto
5ce769ca2c
Add git coommit completions (#854)
Improve git commit completions for nushell
2024-05-28 06:33:48 -05:00
Igor
42732dad6a
Port before_v0.60/with_externals and cleanup (#852) 2024-05-26 16:34:36 -05:00
Igor
840d723d89
Port before v0.60/virtual_environments (#849)
This PR is part of porting all old scripts #221 and includes the
`virtual_environments` module

## 5 files changed

- `conda.nu`: removed, already in
`modules/virtual_enviromnents/conda/nu_conda.nu`
- `conda_deactivate.nu`: also removed, has already been merged with
`nu_conda.nu`
- `README.nu`: removed, similar info in
`modules/virtual_enviromnents/README.md`

- `venv.nu`: ported to `modules/virtual_enviromnents/venv/venv.nu`
- `venv_deactivate.nu`: ported to
`modules/virtual_enviromnents/venv/venv_deactivate.nu`
2024-05-26 12:38:00 -05:00
Igor
275a0f8f26
Port before_v0.60/data_extraction before_v0.60/examples before_v0.60/duplicates (#847)
This PR is part of porting all old scripts #221 and includes a set of
modules:

- `data_extraction`
- `examples` 
- `duplicates`

## 7 changed files:

### `data_extraction`
- `data_extraction/ultimate_extractor.nu`: removed. Has already been
ported to `modules/data_extraction/ultimate_extractor.nu`

### `duplicates`
- `duplicates/duplicates.nu` -> `modules/duplicates/duplicates.nu`
- `duplicates/example.nu` -> `modules/duplicates/example.nu`
- `duplicates/README.md` -> `modules/duplicates/README.md`: unchanged

### `examples`
- `examples/netstat.nu` -> `modules/examples/netstat.nu`
- `examples/date_in_local_timezones.nu` ->
`modules/examples/date_in_local_timezones.nu`
- `befove_v0.60/assets/core_team.nu`: removed. This table has been
embedded into `date_in_local_timezones.nu`
2024-05-26 12:37:29 -05:00
Igor
9d399d8902
Port before_v0.60/config_management before_v0.60/language before_v0.60/prompt before_v0.60/tests (#851)
This PR is part of porting all old scripts #221 and includes a set of
modules:

- `config_management`
- `language`
- `tests`
- `prompt`

## 12 files changed

### `config_management`
This module was removed, because it was related to the old `config.toml`
format
1. `README.md`: removed
2. `config.toml`: removed
3. `startup.nu`: removed

### `language`
4. `playground.nu` : unchanged because this is just `source ...`
5. `std.nu` : unchanged because this is just `source ...`
6. `playground/lib.nu` -> `playground/mod.nu` and all commands have been
exported
7. `std/date.nu` + `export` keyword

### `tests`
This module contained only the usage of `language` module, so I merged
it with `language`
8. `tests/language/std/date.nu` -> `modules/language/tests/date.nu`
9. `main.nu`: removed because it was just `source date.nu`

### `prompt`
10. `git_status_prompt.nu` -> `modules/git_status_prompt.nu` + `export`
keyword
11. `left_and_right_prompt.nu` -> `modules/left_and_right_prompt.nu` +
`export` keyword
12. `README.md` : has been removed as a duplicate of
`modules/prompt/README.md`
2024-05-26 12:37:01 -05:00
Igor
e8df70a406
Port before_v0.60/fuzzy, before_v0.60/ls-mods and before_v0.60/nu_101 (#845)
This PR is part of porting all old scripts #221 and includes a set of
modules:

- fuzzy -> `modules/fuzzy/fuzzy_command_search.nu`
- ls-mods -> `modules/ls-mods`: `ls-less.nu`, `ls-wide.nu` and
`ls-wide-with-color.nu`
- nu_101 -> `modules/nu_101`: `nothing.nu` and `inner_outer_loop.nu`

Edit: `fuzzy` and `nu_101` have been moved to `sourced`
2024-05-26 12:35:59 -05:00
Schweber
7a5424d7d0
modules/nix: init activation-script (#848) 2024-05-26 07:55:40 -05:00
Igor
adaae97990
Port before_v0.60/stdlib_candidate (#850)
This PR is part of porting all old scripts #221 and includes the
`stdlib_candidate` scripts

## 7 changed files

- `flatter.nu`
- `get-column.nu`
- `get-row.nu`
- `get-latest-release-linux.nu`
- `logging.nu`
- `nu_style.nu`
- `print.nu`
2024-05-26 07:49:03 -05:00
Igor
93e71fe6a8
Port before_v0.60/progress_bar before_v0.60/weather before_v0.60/webscrapping (#846)
This PR is part of porting all old scripts #221 and includes only
removing already ported modules:

- `progress_bar` -> `sourced/progress_bar`
- `weather` ->  `modules/weather`
- `webscrapping` -> `sourced/webscrapping`
2024-05-25 13:06:00 -05:00
Igor
15cb7179e2
Port before_v0.60/math, before_v0.60/parsing and before_v0.60/git (#844)
This PR is part of porting all old scripts #221 and includes a set of
small modules:
- `math`
- `parsing`
- `git`
2024-05-25 10:18:21 -05:00
Bob Hyman
429126f3d8
fix regressions noted in 0.93.1 from 0.83: (#843)
1. double pathsep when displaying PWD
2. error 'not a git repo' when PWD outside a repo (`do --ignore-error
{}` no longer eats the stderr text?)
3. improve display when terminal quite narrow (not a regression, just an
improvement)
4. reduce overhead for padding
2024-05-25 08:28:42 -05:00
OJarrisonn_
407a313bbb
feat: add bend completions (#842)
Adds [Bend](https://github.com/HigherOrderCO/Bend) completions for
nushell
2024-05-22 12:41:01 -05:00
Wind
537d7fc4f4
Update conda.nu to use (sys host) rather than (sys).host (#839) 2024-05-22 06:35:50 -05:00
Tai Zeming
bb1fa35baa
feat(yarn): complete runnables(bin & scripts) (#841)
Allow custom-completions/yarn to complete scripts and bins by explicitly
listing existing commands and scripts & bins that loads from the current
path.
2024-05-22 06:30:50 -05:00
winston
66c76a9dbd
fix: adjust for nushell commandline syntax deprecation (#840)
Fixes for changes introduced by
https://github.com/nushell/nushell/pull/12658
2024-05-19 13:33:08 -05:00
Matt Norton
8a77d51e93
Add more detailed poetry completions (#838) 2024-05-15 08:35:02 -05:00