config dump

This commit is contained in:
Bloxx12 2025-07-17 00:55:24 +02:00
commit cf8afe544a
Signed by: faukah
SSH key fingerprint: SHA256:Uj2AXqvtdCA4hn5Hq0ZonhIAyUqI1q4w2sMG3Z1TH7E
6 changed files with 355 additions and 357 deletions

View file

@ -11,50 +11,66 @@ export-env {
$env.config.hooks.env_change.PWD | any { try { get __zoxide_hook } catch { false } }
)
if not $__zoxide_hooked {
$env.config.hooks.env_change.PWD = ($env.config.hooks.env_change.PWD | append {
__zoxide_hook: true,
code: {|_, dir| zoxide add -- $dir}
})
}
}
def "nu-complete zoxide path" [context: string] {
let parts = $context | split row -r "[ /]" | skip 1
{
options: {
sort: false,
completion_algorithm: substring,
case_sensitive: false,
},
completions: (
^zoxide query --list --exclude $env.PWD -- ...$parts
| lines
| first 10
| each {|p| $p | path relative-to $env.PWD | $"($in)/"}
# | each {|p| echo p | path basename}
$env.config.hooks.env_change.PWD = (
$env.config.hooks.env_change.PWD | append {
__zoxide_hook: true
code: {|_ dir| zoxide add -- $dir }
}
)
# | each {|p| echo p | path basename | $"($in)/"}),
}
}
# Jump to a directory using only keywords.
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"
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
# 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
}
# 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")'
}
alias cd = __zoxide_z
alias ci = __zoxide_zi
}
# Jump to a directory using interactive search.
def --env --wrapped __zoxide_zi [...rest:string@"nu-complete zoxide path"] {
cd $'(zoxide query --interactive -- ...$rest | str trim -r -c "\n")'
}
alias cd = __zoxide_z
alias ci = __zoxide_zi
use zoxide-commands *