I made a `toolkit.nu` with a very bare bones struct, this is called via
[`setup-nu`](https://github.com/hustcer/setup-nu) action, and generates
the `check-files.nu` file. After that, another nu instance run that
script to check files one by one. The folder `before_v0.60/` is
excluded.
Rewrite of nushell/nushell#12156 for jdx/mise#1763.
### Why?
Nushell philosophically omits a `set` list mutation. But `$env` is
inherently mutable leading to issues described in nushell/nushell#12148.
`set-env` provides such an operation exclusively for `$env`.
### What changed?
1. Explicit flag instead of implicit list concatenation
2. Expands updates to any `$env` field not only `$env.config`
### How is it used?
```yaml
❯ set-env -h
Gracefully set an environment variable or merge a nested option.
Examples:
Set $env.NUPM_HOME
> set-env NUPM_HOME $'($nu.home-path)/.local/share/nupm'
Add to $env.NU_LIB_DIRS
> set-env --append NU_LIB_DIRS $'($env.NUPM_HOME)/modules'
Set a nested config option
> set-env config.filesize.metric true
Add a config hook
> set-env -a config.hooks.pre_prompt 'ellie | print'
Usage:
> main {flags} <field> <value>
Flags:
-a, --append - Append to the previous value or wrap in a new list
-h, --help - Display the help message for this command
Parameters:
field <cell-path>: The environment variable name or nested option cell path
value <any>: The value to set or append
Input/output types:
╭───┬─────────┬─────────╮
│ # │ input │ output │
├───┼─────────┼─────────┤
│ 0 │ nothing │ nothing │
╰───┴─────────┴─────────╯
```
### How does it work?
```nushell
export def --env main [
field: cell-path
value: any
--append (-a)
]: nothing -> nothing {
# just an alias
def 'get or' [default field] {
get --ignore-errors $field | default $default
}
let value = if $append {
# append to the previous value or empty list
$env | get or [] $field | append $value
} else {
$value
}
# work around nushell/nushell#12168
let field = $field | to text | split row .
let value = match $field {
[_] => $value
# if cell path is nested
[$root, ..$field] => {
let field = $field | into cell-path
# reassigning $env would be an error
# merging reserved names like PWD would be an error
# so merge from 1 level deep instead
$env | get or {} $root | upsert $field $value
}
}
# avoid issues noted above
load-env { ($field | first): $value }
}
```
### Where are the tests?
Pending next PR for nupm integration.
This is some legwork to the CI
- [x] fix one `get-row.nu` before 0.60, just because it was easy
- [x] `modules/formats/to-ini.nu`
- [x] `modules/git/git-v2.nu`
- [x] `modules/git/git.nu`
- [x] `modules/log/log.nu`
- [x] `modules/weather/weatherdark.nu`
- [x] `sourced/api_wrappers/worlframalpha.nu`
- [x] `sourced/cool-oneliners/pwd-short.nu`
- [x] `sourced/github/branch-protections/branch-protections.nu`
- [x] `sourced/gitlab/gitlab.nu`
- [x] `sourced/misc/nu_defs.nu`
- [x] `sourced/update-path.nu`
- [x] `sourced/webscraping/shell_starts.nu`
I moved some auto-generated commands:
- [x] `ack`
- [x] `as`
- [x] `curl`
- [x] `fsarprc`
- [x] `fsarpri`
- [x] `godoc`
- [x] `mysql`
- [x] and `xgettext`
to custom, so we keep the modifications.
I had to comment some of the flags because the parser is not able to
parse some flags. Those are explained in comments
- `gb -d` cleans branches that meet the criteria, if no arguments
- not current
- merged
- `gb -d --no-merged` includes no merged branches
- `gb` (no arguments) output `merged` instead of `no-merged`
- changed `$remote` of `gb` and `gp` to flag
- `remote_branches` return 'remote/branch'
Co-authored-by: nash <nash@iffy.me>
Hi. In the latest zellij (0.39.2), the output of `zellij ls` has been
changed into the following example:
```bash
rectangular-galaxy [Created 9h 21m 46s ago] (EXITED - attach to resurrect)
gregarious-triceratops [Created 22h 48m 32s ago] (EXITED - attach to resurrect)
```
I updated the corresponding parsing code.
- rename `edit` to `nve` to avoid potential conflicts
- `e`, `c`, `v`, `x` export as alias
- nested nvim creates new buffer when no filename as args
- `cwdhist` use Alt+o as default
Co-authored-by: nash <nash@iffy.me>
I added a lot, but not all the `rg` flags. Currently there are 107 and
most of them aren't "results" related, but compatibility for terminals,
negate previous flags when searching multiple regexes and more.
I selected the most useful flags and write them down in the file.
I accept any suggestion!
Hi! Another bug I found, in `git`, you can
```bash
git stash show
```
with no args and should be alright, but the .nu script is requiring a
git name. (maybe for a previous version of git it was needed)
use a unified nvc to start the neovim client, and then have a flag --gui
to start the neovim gui program.
And collect some common GUI startup methods, detect which one exists and
start which one.
---------
Co-authored-by: nash <nash@iffy.me>
Hi!
I found another bug, if you write
```bash
$ gh repo create
```
it leads you to a series of prompts, but the current nu script throws an
error.
I fixed that and `gh repo fork` too, in which you don't necessarily need
an argument.
related to
- https://github.com/nushell/nupm/pull/50
## description
`nu-scripts` was not really a package but rather a set of two module
packages.
this feature has been removed from Nupm in
https://github.com/nushell/nupm/pull/50 and this PR fixes the
`nu-scripts` packages.
> **Note**
> the files in `nu-hooks/` have been moved to `nu-hooks/nu-hooks/` to
fit into the current model of Nupm
this PR does not change anything from the user point of view, apart from
the install that goes from
```nushell
nupm install --path --force .
```
to
```nushell
for pkg in (ls **/package.nuon | get name | path dirname) {
nupm install --force --path $pkg
}
```
This PR extends the existing completion for the pass command to include
all existing subcommands (as of pass v1.7.4). It also adds completions
for the pass-otp and pass-update extensions.
Completions for [pixi](https://github.com/prefix-dev/pixi) generated
from the [last commit
(e330e4b831959452b859079f45fdc77e45d741a9)](e330e4b831)
to date using the clap auto generation.
Parser did a good job here, explaining
```
Error: × Deprecated: --flag: bool
╭─[C:\...\nu_scripts\custom-completions\winget\winget-completions.nu:27:1]
27 │
28 │ def "nu-complete winget flagify" [name: string, value: any, --short(-s): bool] {
· ──┬─
· ╰── `--flag: bool` is deprecated and will be removed in 0.90. Please use `--flag` instead, more info: https://www.nushell.sh/book/custom_commands.html
29 │ let flag_start = if $short { '-' } else { '--' }
╰────
```
is not possible anymore, so I removed all the `: bool`s and sourced the
script correctly!
Sorry, I forgot to use `fill -c` and implemented `str repeat` with
similar function. Now change it back
Added a `log` helper function to avoid the frequent need to adjust the
output format
The original `lg` with a similar name was changed to `show`, but it is
basically only used for internal debugging.
I'm not sure if these should be merged, feel free to do whatever you
want
Co-authored-by: nash <nash@iffy.me>
A nu_101 script to give some examples of how to treat lists like other
data structures that nushell doesn't have natively. Namely queues,
stacks, and sets (and multisets sort of).
I'm also considering making some examples for trees and graphs, probably
using tables, although I might put them in another script so it doesn't
get too long.