diff --git a/CHANGELOG.md b/CHANGELOG.md index de4c2ca..abc4dfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Nushell: `z` now handles relative paths through symlinked directories. - POSIX: fix `z` failing to enter directories whose names start with `-`. - Build: fix compilation failing when the source directory is read-only. +- PowerShell: the prompt hook no longer resets `$LASTEXITCODE`. ## [0.10.0] - 2026-07-04 diff --git a/templates/powershell.txt b/templates/powershell.txt index 37b60f4..a61866f 100644 --- a/templates/powershell.txt +++ b/templates/powershell.txt @@ -93,7 +93,9 @@ if ($global:__zoxide_hooked -ne 1) { if ($null -ne $__zoxide_prompt_old) { & $__zoxide_prompt_old } + $exitCode = Microsoft.PowerShell.Utility\Get-Variable LASTEXITCODE -Scope Global -ErrorAction Ignore -ValueOnly $null = __zoxide_hook + $global:LASTEXITCODE = $exitCode } } {%- endif %}