mirror of
https://github.com/Llewellynvdm/zoxide.git
synced 2024-12-28 03:45:06 +00:00
90 lines
2.5 KiB
Plaintext
90 lines
2.5 KiB
Plaintext
{%- let section = "# =============================================================================\n#" -%}
|
|
{%- let not_configured = "# -- not configured --" -%}
|
|
|
|
# Code generated by zoxide. DO NOT EDIT.
|
|
|
|
{{ section }}
|
|
# Hook configuration for zoxide.
|
|
#
|
|
|
|
{% if hook == InitHook::None -%}
|
|
{{ not_configured }}
|
|
|
|
{%- else -%}
|
|
# Initialize hook to add new entries to the database.
|
|
if (not ($env | default false __zoxide_hooked | get __zoxide_hooked)) {
|
|
$env.__zoxide_hooked = true
|
|
{%- if hook == InitHook::Prompt %}
|
|
$env.config = ($env | default {} config).config
|
|
$env.config = ($env.config | default {} hooks)
|
|
$env.config = ($env.config | update hooks ($env.config.hooks | default [] pre_prompt))
|
|
$env.config = ($env.config | update hooks.pre_prompt ($env.config.hooks.pre_prompt | append { ||
|
|
zoxide add -- $env.PWD
|
|
}))
|
|
{%- else if hook == InitHook::Pwd %}
|
|
$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.env_change.PWD | append {|_, dir|
|
|
zoxide add -- $dir
|
|
}))
|
|
{%- endif %}
|
|
}
|
|
|
|
{%- endif %}
|
|
|
|
{{ section }}
|
|
# When using zoxide with --no-cmd, alias these internal functions as desired.
|
|
#
|
|
|
|
# Jump to a directory using only keywords.
|
|
def-env __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
|
|
{%- if echo %}
|
|
echo $env.PWD
|
|
{%- endif %}
|
|
}
|
|
|
|
# Jump to a directory using interactive search.
|
|
def-env __zoxide_zi [...rest:string] {
|
|
cd $'(zoxide query --interactive -- $rest | str trim -r -c "\n")'
|
|
{%- if echo %}
|
|
echo $env.PWD
|
|
{%- endif %}
|
|
}
|
|
|
|
{{ section }}
|
|
# Commands for zoxide. Disable these using --no-cmd.
|
|
#
|
|
|
|
{%- match cmd %}
|
|
{%- when Some with (cmd) %}
|
|
|
|
alias {{cmd}} = __zoxide_z
|
|
alias {{cmd}}i = __zoxide_zi
|
|
|
|
{%- when None %}
|
|
|
|
{{ not_configured }}
|
|
|
|
{%- endmatch %}
|
|
|
|
{{ section }}
|
|
# Add this to your env file (find it by running `$nu.env-path` in Nushell):
|
|
#
|
|
# zoxide init nushell | save -f ~/.zoxide.nu
|
|
#
|
|
# Now, add this to the end of your config file (find it by running
|
|
# `$nu.config-path` in Nushell):
|
|
#
|
|
# source ~/.zoxide.nu
|
|
#
|
|
# Note: zoxide only supports Nushell v0.73.0 and above.
|