Compare commits

...

6 Commits

Author SHA1 Message Date
Yash Thakur 3ec1d13315
Merge c47f506313 into 194f8e31e4 2025-10-06 16:15:32 -07:00
Ajeet D'Souza 194f8e31e4
Update README.md 2025-10-03 02:59:45 +05:30
Ajeet D'Souza eb7b08fed3
Update README.md 2025-09-30 18:34:43 +05:30
ysthakur c47f506313
Only trim left; use prefix algo 2025-06-09 22:15:29 -04:00
Yash Thakur e516852566
Merge branch 'main' into custom-completer 2025-06-07 22:15:05 -04:00
ysthakur df52401611
Provide completions for Nushell 2025-05-23 22:11:08 -04:00
2 changed files with 56 additions and 21 deletions

View File

@ -12,12 +12,12 @@
<sup>Special thanks to:</sup>
<!-- markdownlint-disable-next-line MD013 -->
<div><img alt="Sponsored by Warp" width="230" src="https://raw.githubusercontent.com/warpdotdev/brand-assets/refs/heads/main/Github/Sponsor/Warp-Github-LG-03.png" /></div>
<div><a href="https://go.warp.dev/zoxide"><img alt="Sponsored by Warp" width="230" src="https://raw.githubusercontent.com/warpdotdev/brand-assets/refs/heads/main/Github/Sponsor/Warp-Github-LG-03.png" /></a></div>
<div><sup><b>Warp, built for coding with multiple AI agents.</b></sup></div>
<div><sup>Available for macOS, Linux, and Windows.</sup></div>
<div><sup>
Visit
<a href="https://www.warp.dev/?utm_source=github&utm_medium=referral&utm_campaign=zoxide_20231001"><u>warp.dev</u></a>
<a href="https://go.warp.dev/zoxide"><u>warp.dev</u></a>
to learn more.
</sup></div>

View File

@ -55,29 +55,64 @@ export-env {
# When using zoxide with --no-cmd, alias these internal functions as desired.
#
# Jump to a directory using only keywords.
def --env --wrapped __zoxide_z [...rest: string] {
let path = match $rest {
[] => {'~'},
[ '-' ] => {'-'},
[ $arg ] if ($arg | path expand | path type) == 'dir' => {$arg}
_ => {
^zoxide query --exclude $env.PWD -- ...$rest | str trim -r -c "\n"
# For hiding the "nu-complete zoxide path" command
module zoxide-commands {
def "nu-complete zoxide path" [context: string] {
let parts = $context | str trim --left | split row " " | skip 1 | each { str downcase }
let completions = (
^zoxide query --list --exclude $env.PWD -- ...$parts
| lines
| each { |dir|
if ($parts | length) <= 1 {
$dir
} else {
let dir_lower = $dir | str downcase
let rem_start = $parts | drop 1 | reduce --fold 0 { |part, rem_start|
($dir_lower | str index-of --range $rem_start.. $part) + ($part | str length)
}
{
value: ($dir | str substring $rem_start..),
description: $dir
}
}
})
{
options: {
sort: false,
completion_algorithm: prefix,
positional: false,
case_sensitive: false,
},
completions: $completions,
}
}
cd $path
{%- if echo %}
echo $env.PWD
{%- endif %}
# Jump to a directory using only keywords.
export def --env --wrapped __zoxide_z [...rest: string@"nu-complete zoxide path"] {
let path = match $rest {
[] => {'~'},
[ '-' ] => {'-'},
[ $arg ] if ($arg | path expand | path type) == 'dir' => {$arg}
_ => {
^zoxide query --exclude $env.PWD -- ...$rest | str trim -r -c "\n"
}
}
cd $path
{%- if echo %}
echo $env.PWD
{%- endif %}
}
# Jump to a directory using interactive search.
export def --env --wrapped __zoxide_zi [...rest:string@"nu-complete zoxide path"] {
cd $'(^zoxide query --interactive -- ...$rest | str trim -r -c "\n")'
{%- if echo %}
echo $env.PWD
{%- endif %}
}
}
# Jump to a directory using interactive search.
def --env --wrapped __zoxide_zi [...rest:string] {
cd $'(^zoxide query --interactive -- ...$rest | str trim -r -c "\n")'
{%- if echo %}
echo $env.PWD
{%- endif %}
}
use zoxide-commands *
{{ section }}
# Commands for zoxide. Disable these using --no-cmd.