From 095e9d3d6c428184c7d69eb285fc4a7e545bd89c Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Fri, 15 Oct 2021 08:27:09 +0530 Subject: [PATCH] Fix hook initialization on Powershell (#280) --- templates/powershell.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 }}