diff --git a/templates/powershell.txt b/templates/powershell.txt index 09cb848..b1e9896 100644 --- a/templates/powershell.txt +++ b/templates/powershell.txt @@ -30,7 +30,15 @@ function __zoxide_cd($dir, $literal) { $dir = if ($literal) { Set-Location -LiteralPath $dir -Passthru -ErrorAction Stop } else { - Set-Location -Path $dir -Passthru -ErrorAction Stop + if ($dir -eq '-' -and ($PSVersionTable.PSVersion -ge 6.1)) { + Write-Error "cd - is not supported below PowerShell 6.1. Please upgrade your version of PowerShell." + } + elseif ($dir -eq '+' -and ($PSVersionTable.PSVersion -ge 6.2)) { + Write-Error "cd + is not supported below PowerShell 6.2. Please upgrade your version of PowerShell." + } + else { + Set-Location -Path $dir -Passthru -ErrorAction Stop + } } {%- if echo %} Write-Output $dir.Path @@ -74,7 +82,7 @@ if ($__zoxide_hooked -ne 1) { } else { Write-Error ("`n" + - "zoxide: PWD hooks are not supported below powershell 6.`n" + + "zoxide: PWD hooks are not supported below PowerShell 6.`n" + " Use 'zoxide init powershell --hook prompt' instead.") } {%- endmatch %}