Minor changes

This commit is contained in:
Ajeet D'Souza 2025-02-10 01:28:53 +05:30
parent 0450775af9
commit 12292cf826
1 changed files with 24 additions and 28 deletions

View File

@ -13,44 +13,40 @@
{%- else -%} {%- else -%}
# Initialize hook to add new entries to the database. # Initialize hook to add new entries to the database.
export-env { export-env {
{%- if hook == InitHook::Prompt %} {%- if hook == InitHook::Prompt %}
let hooked = ( $env.config = (
$env.config?.hooks?.pre_prompt? $env.config?
| default [] | default {}
| any { try {get zoxide} catch { false } } | upsert hooks { default {} }
| upsert hooks.pre_prompt { default [] }
) )
if not $hooked { let __zoxide_hooked = (
$env.config = ( $env.config.hooks.pre_prompt | any { try { get __zoxide_hook } catch { false } }
$env.config? | default {} )
| upsert hooks { default {} } if not $__zoxide_hooked {
| upsert hooks.pre_prompt { default [] }
)
$env.config.hooks.pre_prompt = ($env.config.hooks.pre_prompt | append { $env.config.hooks.pre_prompt = ($env.config.hooks.pre_prompt | append {
zoxide: true, __zoxide_hook: true,
code: {|| zoxide add -- $env.PWD} code: {|| zoxide add -- $env.PWD}
}) })
} }
{%- else if hook == InitHook::Pwd %} {%- else if hook == InitHook::Pwd %}
let hooked = ( $env.config = (
$env.config?.hooks?.env_change?.PWD? $env.config?
| default [] | default {}
| any { try {get zoxide} catch { false } } | upsert hooks { default {} }
| upsert hooks.env_change { default {} }
| upsert hooks.env_change.PWD { default [] }
) )
if not $hooked { let __zoxide_hooked = (
$env.config = ( $env.config.hooks.env_change.PWD | any { try { get __zoxide_hook } catch { false } }
$env.config? | default {} )
| upsert hooks { default {} } if not $__zoxide_hooked {
| upsert hooks.env_change { default {} }
| upsert hooks.env_change.PWD { default [] }
)
$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: true, __zoxide_hook: true,
code: {|_, dir| zoxide add -- $dir} code: {|_, dir| zoxide add -- $dir}
}) })
} }
{%- endif %} {%- endif %}
} }
{%- endif %} {%- endif %}