This commit is contained in:
Juhan 2026-07-14 12:44:43 +00:00 committed by GitHub
commit 36629064b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 35 additions and 21 deletions

View File

@ -9,9 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Nushell: `z` now supports Space-Tab completions.
### Fixed
- Bash/Zsh: fix `z` failing on Cygwin/MSYS2 due to `cygpath` being passed a bad string.
- Bash/Zsh: `z` failing on Cygwin/MSYS2 due to `cygpath` being passed a bad string.
- Nushell: `z` now handles relative paths through symlinked directories.
## [0.10.0] - 2026-07-04

View File

@ -268,7 +268,7 @@ zoxide can be installed in 4 easy steps:
> ```
>
> **Note:**
> zoxide only supports Nushell v0.89.0+.
> zoxide only supports Nushell v0.110.0+.
</details>

View File

@ -45,7 +45,7 @@ Now, add this to the \fBend\fR of your config file (find it by running
\fBsource ~/.zoxide.nu\fR
.fi
.sp
Note: zoxide only supports Nushell v0.89.0+.
Note: zoxide only supports Nushell v0.110.0+.
.TP
.B powershell
Add this to the \fBend\fR of your config file (find it by running \fBecho

View File

@ -14,14 +14,9 @@
# Initialize hook to add new entries to the database.
export-env {
{%- if hook == InitHook::Prompt %}
$env.config = (
$env.config?
| default {}
| upsert hooks { default {} }
| upsert hooks.pre_prompt { default [] }
)
let __zoxide_hooked = (
$env.config.hooks.pre_prompt | any { try { get __zoxide_hook } catch { false } }
$env.config.hooks.pre_prompt
| any { get __zoxide_hook? | default false }
)
if not $__zoxide_hooked {
$env.config.hooks.pre_prompt = ($env.config.hooks.pre_prompt | append {
@ -30,18 +25,12 @@ export-env {
})
}
{%- else if hook == InitHook::Pwd %}
$env.config = (
$env.config?
| default {}
| upsert hooks { default {} }
| upsert hooks.env_change { default {} }
| upsert hooks.env_change.PWD { default [] }
)
let __zoxide_hooked = (
$env.config.hooks.env_change.PWD | any { try { get __zoxide_hook } catch { false } }
$env.config.hooks.env_change.PWD? | default []
| any { get __zoxide_hook? | default false }
)
if not $__zoxide_hooked {
$env.config.hooks.env_change.PWD = ($env.config.hooks.env_change.PWD | append {
$env.config.hooks.env_change.PWD = ($env.config.hooks.env_change.PWD? | append {
__zoxide_hook: true,
code: {|_, dir| ^zoxide add -- $dir}
})
@ -51,12 +40,33 @@ export-env {
{%- endif %}
{{ section }}
# Completion for __zoxide_z
#
def "nu-complete __zoxide_z" [context: string] {
let ast = ast --flatten $context | skip 1 # skip the command name
# If the user has typed a space after the first argument, use the custom
# completer. If not, use the built-in directory completion.
if ($ast | is-empty) { return null }
if $ast.0.span.end >= ($context | str length) { return null }
^zoxide query --exclude $env.PWD --interactive -- ...$ast.content
| if $in starts-with $"($nu.home-dir)(char psep)" { str replace $nu.home-dir "~" } else {}
| [{
display_override: $in,
value: ($in | debug --raw-value),
span: { start: ($ast | first).span.start, end: ($ast | last).span.end }
}]
}
{{ section }}
# When using zoxide with --no-cmd, alias these internal functions as desired.
#
# Jump to a directory using only keywords.
export def --env --wrapped __zoxide_z [...rest: directory] {
export def --env --wrapped __zoxide_z [...rest: directory@"nu-complete __zoxide_z"] {
match $rest {
[] => { cd ~ },
[ '-' ] => { cd - },
@ -104,4 +114,4 @@ export alias {{cmd}}i = __zoxide_zi
#
# source ~/.zoxide.nu
#
# Note: zoxide only supports Nushell v0.89.0+.
# Note: zoxide only supports Nushell v0.110.0+.