Closed IlyaVassyutovich closed 2 months ago
You may need to upgrade zoxide - Nushell has not reached v1.0 yet, and makes a lot of backward-incompatible changes every release.
Also, you appear to be generating the source file manually, unlike the instructions in the README. If you update zoxide, the Nushell script may change, causing your config to break.
@IlyaVassyutovich I had the same issue. Zoxide generates init nu-script which doesn't work.
Tested in nushell 0.92.2
To make it work I:
zoxide init nushell | save -f ~/.zoxide.nu
in nu-env file to prevent script regeneration.~/zoxide.nu
to
# Code generated by zoxide. DO NOT EDIT.
#
#
if (not ($env | default false zoxide_hooked | get __zoxide_hooked)) { $env.zoxide_hooked = true $env.config = ($env | default {} config).config $env.config = ($env.config | default {} hooks) $env.config = ($env.config | update hooks ($env.config.hooks | default {} env_change)) $env.config = ($env.config | update hooks.env_change ($env.config.hooks.env_change | default [] PWD)) $env.config = ($env.config | update hooks.env_change.PWD ($env.config.hooks.envchange.PWD | append {|, dir| zoxide add -- $dir })) }
#
#
def --env --wrapped __zoxide_z [...rest:string] { let arg0 = ($rest | append '~').0 let path = if (($rest | length) <= 1) and ($arg0 == '-' or ($arg0 | path expand | path type) == dir) { $arg0 } else { (zoxide query --exclude $env.PWD -- ...$rest | str trim -r -c "\n") } cd $path }
def --env --wrapped __zoxide_zi [...rest:string] { cd $'(zoxide query --interactive -- ...$rest | str trim -r -c "\n")' }
#
#
alias cd = __zoxide_z alias cdi = __zoxide_zi
#
$nu.env-path
in Nushell):#
#
$nu.config-path
in Nushell):#
#
3. ???
4. PROFIT
So, mainly changes were:
1. Changing `def-env` to `def --env --wrapped`
2. Adding spread to `$rest` variable
3. I've made alias to `cd` and `cdi` - you may don't want to do that.
@mrjackphil did you try upgrading zoxide?
I just today installed the zoxide and tried to run it. So I was sure that I'm using the latest version. But...
I installed it using chocolatey. Current version of zoxide in there is 0.9.2. Latest is 0.9.4. I've updated zoxide manually and it seems to resolve the problem.
So, thank you @ajeetdsouza for reply and sorry for oversight.
How to reproduce
Have a nu-shell
Build zoxide-init script
Add zoxide-init script to nu.config:
Start new instance of the shell
Misc
I'm not yet proficient with nu-language, but it seems like spread operator with "rest"-argumets does not work as intended with
def-env
.