From b7a884fbe089fe4ea5954639cff898f0e216527e Mon Sep 17 00:00:00 2001 From: William Wei <37211959+WiIIiamWei@users.noreply.github.com> Date: Mon, 7 Oct 2024 20:35:04 +0800 Subject: [PATCH] Fix issues with PowerShell env variables --- templates/powershell.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/templates/powershell.txt b/templates/powershell.txt index 86b1966..d2579e0 100644 --- a/templates/powershell.txt +++ b/templates/powershell.txt @@ -27,6 +27,7 @@ function global:__zoxide_pwd { # cd + custom logic based on the value of _ZO_ECHO. function global:__zoxide_cd($dir, $literal) { + $dir = [System.Environment]::ExpandEnvironmentVariables($dir) $dir = if ($literal) { Set-Location -LiteralPath $dir -Passthru -ErrorAction Stop } else { @@ -106,8 +107,8 @@ function global:__zoxide_z { elseif ($args.Length -eq 1 -and ($args[0] -eq '-' -or $args[0] -eq '+')) { __zoxide_cd $args[0] $false } - elseif ($args.Length -eq 1 -and (Test-Path $args[0] -PathType Container)) { - __zoxide_cd $args[0] $true + elseif ($args.Length -eq 1 -and (Test-Path ([System.Environment]::ExpandEnvironmentVariables($args[0])) -PathType Container)) { + __zoxide_cd ([System.Environment]::ExpandEnvironmentVariables($args[0])) $true } else { $result = __zoxide_pwd