diff --git a/README.md b/README.md index c45e254..661ba39 100644 --- a/README.md +++ b/README.md @@ -354,7 +354,7 @@ However, Cmder can in fact run in a variety of other terminal emulators, and eve ⚠ *Note:* Cmder includes built-in support for Windows Terminal directory tracking via OSC 9;9 sequences. This enables "Duplicate Tab" and "Split Pane" features to preserve the current working directory for both `cmd.exe` and PowerShell sessions. -⚠ *Note:* Cmder also includes built-in support for [Windows Terminal shell integration](https://learn.microsoft.com/en-us/windows/terminal/tutorials/shell-integration) via OSC 133 sequences (A, B, C) for PowerShell sessions. This enables features like command navigation (jump between commands), command selection, visual command separators, and improved command history management in Windows Terminal. +⚠ *Note:* Cmder also includes built-in support for [Windows Terminal shell integration](https://learn.microsoft.com/en-us/windows/terminal/tutorials/shell-integration) via OSC 133 sequences (A, B, C, D) for PowerShell sessions. This enables features like command navigation (jump between commands), command selection, visual command separators, command exit code tracking, and improved command history management in Windows Terminal. For instructions on how to integrate Cmder with your IDE, please read our [Wiki section](https://github.com/cmderdev/cmder/wiki#cmder-integration). diff --git a/vendor/profile.ps1 b/vendor/profile.ps1 index c77e81a..42728e2 100644 --- a/vendor/profile.ps1 +++ b/vendor/profile.ps1 @@ -221,6 +221,14 @@ if ( $(Get-Command prompt).Definition -match 'PS \$\(\$executionContext.SessionS $lastSUCCESS = $? $realLastExitCode = $LastExitCode + # Emit OSC 133;D sequence for Windows Terminal shell integration + # This marks the end of command execution with the exit code + # Must be emitted before OSC 133;A (start of next prompt) + # Only active in Windows Terminal ($env:WT_SESSION) + if ($env:WT_SESSION) { + Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]133;D;$realLastExitCode$([char]7)" + } + # Emit OSC 9;9 sequence for Windows Terminal directory tracking # This enables "Duplicate Tab" and "Split Pane" to preserve the working directory # Only active in Windows Terminal ($env:WT_SESSION) or ConEmu ($env:ConEmuPID)