diff --git a/src/cli/snapshots/mise__cli__deactivate__tests__deactivate-2.snap b/src/cli/snapshots/mise__cli__deactivate__tests__deactivate-2.snap index ac9a1130d..80a78dfa6 100644 --- a/src/cli/snapshots/mise__cli__deactivate__tests__deactivate-2.snap +++ b/src/cli/snapshots/mise__cli__deactivate__tests__deactivate-2.snap @@ -1,10 +1,12 @@ --- source: src/cli/deactivate.rs expression: output +snapshot_kind: text --- export PATH='$PATH' -precmd_functions=( ${precmd_functions:#_mise_hook} ) +precmd_functions=( ${precmd_functions:#_mise_hook_cmd} ) chpwd_functions=( ${chpwd_functions:#_mise_hook} ) +unset -f _mise_hook_cmd unset -f _mise_hook unset -f mise unset MISE_SHELL diff --git a/src/shell/snapshots/mise__shell__zsh__tests__activate.snap b/src/shell/snapshots/mise__shell__zsh__tests__activate.snap index 519352327..ad57a0a06 100644 --- a/src/shell/snapshots/mise__shell__zsh__tests__activate.snap +++ b/src/shell/snapshots/mise__shell__zsh__tests__activate.snap @@ -1,6 +1,7 @@ --- source: src/shell/zsh.rs expression: "zsh.activate(exe, \" --status\".into())" +snapshot_kind: text --- export MISE_SHELL=zsh export __MISE_ORIG_PATH="$PATH" @@ -29,9 +30,14 @@ mise() { _mise_hook() { eval "$(/some/dir/mise hook-env --status -s zsh)"; } +_mise_hook_cmd() { + if [[ -n "$ZLAST_COMMANDS" ]]; then + _mise_hook; + fi +} typeset -ag precmd_functions; -if [[ -z "${precmd_functions[(r)_mise_hook]+1}" ]]; then - precmd_functions=( _mise_hook ${precmd_functions[@]} ) +if [[ -z "${precmd_functions[(r)_mise_hook_cmd]+1}" ]]; then + precmd_functions=( _mise_hook_cmd ${precmd_functions[@]} ) fi typeset -ag chpwd_functions; if [[ -z "${chpwd_functions[(r)_mise_hook]+1}" ]]; then diff --git a/src/shell/snapshots/mise__shell__zsh__tests__deactivate.snap b/src/shell/snapshots/mise__shell__zsh__tests__deactivate.snap index 65c266ee7..bdb7d2b79 100644 --- a/src/shell/snapshots/mise__shell__zsh__tests__deactivate.snap +++ b/src/shell/snapshots/mise__shell__zsh__tests__deactivate.snap @@ -1,9 +1,11 @@ --- source: src/shell/zsh.rs expression: replace_path(&deactivate) +snapshot_kind: text --- -precmd_functions=( ${precmd_functions:#_mise_hook} ) +precmd_functions=( ${precmd_functions:#_mise_hook_cmd} ) chpwd_functions=( ${chpwd_functions:#_mise_hook} ) +unset -f _mise_hook_cmd unset -f _mise_hook unset -f mise unset MISE_SHELL diff --git a/src/shell/zsh.rs b/src/shell/zsh.rs index bce0c6772..1952b0e3e 100644 --- a/src/shell/zsh.rs +++ b/src/shell/zsh.rs @@ -44,9 +44,14 @@ impl Shell for Zsh { _mise_hook() {{ eval "$({exe} hook-env{flags} -s zsh)"; }} + _mise_hook_cmd() {{ + if [[ -n "$ZLAST_COMMANDS" ]]; then + _mise_hook; + fi + }} typeset -ag precmd_functions; - if [[ -z "${{precmd_functions[(r)_mise_hook]+1}}" ]]; then - precmd_functions=( _mise_hook ${{precmd_functions[@]}} ) + if [[ -z "${{precmd_functions[(r)_mise_hook_cmd]+1}}" ]]; then + precmd_functions=( _mise_hook_cmd ${{precmd_functions[@]}} ) fi typeset -ag chpwd_functions; if [[ -z "${{chpwd_functions[(r)_mise_hook]+1}}" ]]; then @@ -80,8 +85,9 @@ impl Shell for Zsh { fn deactivate(&self) -> String { formatdoc! {r#" - precmd_functions=( ${{precmd_functions:#_mise_hook}} ) + precmd_functions=( ${{precmd_functions:#_mise_hook_cmd}} ) chpwd_functions=( ${{chpwd_functions:#_mise_hook}} ) + unset -f _mise_hook_cmd unset -f _mise_hook unset -f mise unset MISE_SHELL