Add OSC 133;D support for command exit code tracking

Co-authored-by: DRSDavidSoft <4673812+DRSDavidSoft@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-08 22:27:38 +00:00
parent b9246177c0
commit bbd7507b4e
2 changed files with 9 additions and 1 deletions

View File

@@ -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 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). For instructions on how to integrate Cmder with your IDE, please read our [Wiki section](https://github.com/cmderdev/cmder/wiki#cmder-integration).

8
vendor/profile.ps1 vendored
View File

@@ -221,6 +221,14 @@ if ( $(Get-Command prompt).Definition -match 'PS \$\(\$executionContext.SessionS
$lastSUCCESS = $? $lastSUCCESS = $?
$realLastExitCode = $LastExitCode $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 # Emit OSC 9;9 sequence for Windows Terminal directory tracking
# This enables "Duplicate Tab" and "Split Pane" to preserve the working directory # This enables "Duplicate Tab" and "Split Pane" to preserve the working directory
# Only active in Windows Terminal ($env:WT_SESSION) or ConEmu ($env:ConEmuPID) # Only active in Windows Terminal ($env:WT_SESSION) or ConEmu ($env:ConEmuPID)