1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-07-31 14:17:45 +00:00

Autojump argument parsing (#1077)

I've changed the number of arguments of `def --env j [dir]` to `def
--env j [...dir]`, this change makes the behaviour more like the `j`
autojump you can find in other shells where an arbitrary number of
inputs are given to it.

ie. 
In zsh:

![image](https://github.com/user-attachments/assets/5de5611e-2681-46a0-93c4-d6e68922df13)

In nushell old j:

![image](https://github.com/user-attachments/assets/966dc6b0-cd9f-4d19-b662-e561c42bca83)

In nushell new j:

![image](https://github.com/user-attachments/assets/a73d10a1-1313-4dd8-815e-9e8a15a16101)
This commit is contained in:
Direwolfesp 2025-03-23 14:25:08 +01:00 committed by GitHub
parent 13de3375c0
commit e956708244
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,9 +14,9 @@ def autojump_add_to_database [dir] {
$env.AUTOJUMP_SOURCED = 1
autojump --add $dir
}
def --env j [dir] {
def --env j [...dir] {
$env.AUTOJUMP_SOURCED = 1
cd (autojump $dir)
cd (autojump ...$dir)
}
$env.config = ($env.config | upsert hooks.env_change.PWD {|config|
let val = ($config | get -i hooks.env_change.PWD)