diff --git a/templates/powershell.txt b/templates/powershell.txt index e53d39a..ad8323b 100644 --- a/templates/powershell.txt +++ b/templates/powershell.txt @@ -34,7 +34,11 @@ function __zoxide_hook { } # Initialize hook. -if (-Not (Get-Command '__zoxide_hook' -ErrorAction SilentlyContinue)) { +{# Initialize $__zoxide_hooked if it does not exist. Removing this will cause + # an unset variable error in StrictMode. #} +$__zoxide_hooked = (Get-Variable __zoxide_hooked -ValueOnly -ErrorAction SilentlyContinue) +if ($__zoxide_hooked -ne 1) { + $__zoxide_hooked = 1 {%- match hook %} {%- when InitHook::None %} {{ not_configured }}