2021-04-08 18:35:42 +00:00
|
|
|
{%- let section = "# =============================================================================\n#" -%}
|
|
|
|
{%- let not_configured = "# -- not configured --" -%}
|
2021-03-31 16:45:43 +00:00
|
|
|
|
2021-08-05 08:52:12 +00:00
|
|
|
# Code generated by zoxide. DO NOT EDIT.
|
|
|
|
|
2021-04-08 18:35:42 +00:00
|
|
|
{{ section }}
|
2021-03-31 16:45:43 +00:00
|
|
|
# Hook configuration for zoxide.
|
|
|
|
#
|
|
|
|
|
2022-08-12 20:32:43 +00:00
|
|
|
{% if hook == InitHook::None -%}
|
|
|
|
{{ not_configured }}
|
2022-04-22 07:41:11 +00:00
|
|
|
|
2022-08-12 20:32:43 +00:00
|
|
|
{%- else -%}
|
|
|
|
# Initialize hook to add new entries to the database.
|
2023-01-07 17:28:10 +00:00
|
|
|
if (not ($env | default false __zoxide_hooked | get __zoxide_hooked)) {
|
2023-06-30 19:31:08 +00:00
|
|
|
$env.__zoxide_hooked = true
|
2022-08-12 20:32:43 +00:00
|
|
|
{%- if hook == InitHook::Prompt %}
|
2023-06-30 19:31:08 +00:00
|
|
|
$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 { ||
|
2023-01-07 17:28:10 +00:00
|
|
|
zoxide add -- $env.PWD
|
|
|
|
}))
|
2022-08-12 20:32:43 +00:00
|
|
|
{%- else if hook == InitHook::Pwd %}
|
2023-06-30 19:31:08 +00:00
|
|
|
$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|
|
2023-01-07 17:28:10 +00:00
|
|
|
zoxide add -- $dir
|
|
|
|
}))
|
2022-08-12 20:32:43 +00:00
|
|
|
{%- endif %}
|
2023-01-07 17:28:10 +00:00
|
|
|
}
|
2022-04-22 07:41:11 +00:00
|
|
|
|
2022-08-12 20:32:43 +00:00
|
|
|
{%- endif %}
|
2021-03-31 16:45:43 +00:00
|
|
|
|
2021-04-08 18:35:42 +00:00
|
|
|
{{ section }}
|
2022-04-22 07:41:11 +00:00
|
|
|
# When using zoxide with --no-cmd, alias these internal functions as desired.
|
2021-03-31 16:45:43 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# Jump to a directory using only keywords.
|
2022-04-22 07:41:11 +00:00
|
|
|
def-env __zoxide_z [...rest:string] {
|
|
|
|
let arg0 = ($rest | append '~').0
|
2022-12-08 17:54:43 +00:00
|
|
|
let path = if (($rest | length) <= 1) and ($arg0 == '-' or ($arg0 | path expand | path type) == dir) {
|
2022-04-22 07:41:11 +00:00
|
|
|
$arg0
|
|
|
|
} else {
|
|
|
|
(zoxide query --exclude $env.PWD -- $rest | str trim -r -c "\n")
|
|
|
|
}
|
|
|
|
cd $path
|
2021-05-05 23:01:57 +00:00
|
|
|
{%- if echo %}
|
2022-04-22 07:41:11 +00:00
|
|
|
echo $env.PWD
|
2021-05-05 23:01:57 +00:00
|
|
|
{%- endif %}
|
2021-03-31 16:45:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Jump to a directory using interactive search.
|
2022-04-22 07:41:11 +00:00
|
|
|
def-env __zoxide_zi [...rest:string] {
|
2023-05-06 15:18:19 +00:00
|
|
|
cd $'(zoxide query --interactive -- $rest | str trim -r -c "\n")'
|
2021-04-08 18:35:42 +00:00
|
|
|
{%- if echo %}
|
2022-04-22 07:41:11 +00:00
|
|
|
echo $env.PWD
|
2021-04-08 18:35:42 +00:00
|
|
|
{%- endif %}
|
2021-03-31 16:45:43 +00:00
|
|
|
}
|
|
|
|
|
2021-04-08 18:35:42 +00:00
|
|
|
{{ section }}
|
2022-04-10 22:11:51 +00:00
|
|
|
# Commands for zoxide. Disable these using --no-cmd.
|
2021-03-31 16:45:43 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
{%- match cmd %}
|
|
|
|
{%- when Some with (cmd) %}
|
|
|
|
|
2021-06-02 21:19:21 +00:00
|
|
|
alias {{cmd}} = __zoxide_z
|
|
|
|
alias {{cmd}}i = __zoxide_zi
|
2021-03-31 16:45:43 +00:00
|
|
|
|
|
|
|
{%- when None %}
|
2021-04-08 18:35:42 +00:00
|
|
|
|
|
|
|
{{ not_configured }}
|
2021-03-31 16:45:43 +00:00
|
|
|
|
|
|
|
{%- endmatch %}
|
|
|
|
|
2021-04-08 18:35:42 +00:00
|
|
|
{{ section }}
|
2022-04-22 07:41:11 +00:00
|
|
|
# Add this to your env file (find it by running `$nu.env-path` in Nushell):
|
|
|
|
#
|
2023-01-07 17:28:10 +00:00
|
|
|
# zoxide init nushell | save -f ~/.zoxide.nu
|
2022-04-22 07:41:11 +00:00
|
|
|
#
|
|
|
|
# Now, add this to the end of your config file (find it by running
|
|
|
|
# `$nu.config-path` in Nushell):
|
2021-04-27 12:07:38 +00:00
|
|
|
#
|
2022-04-22 07:41:11 +00:00
|
|
|
# source ~/.zoxide.nu
|
2021-04-27 12:07:38 +00:00
|
|
|
#
|
2022-12-08 17:54:43 +00:00
|
|
|
# Note: zoxide only supports Nushell v0.73.0 and above.
|