Skip to content

Commit bbd7507

Browse files
CopilotDRSDavidSoft
andcommitted
Add OSC 133;D support for command exit code tracking
Co-authored-by: DRSDavidSoft <[email protected]>
1 parent b924617 commit bbd7507

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ However, Cmder can in fact run in a variety of other terminal emulators, and eve
354354

355355
*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.
356356

357-
*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.
357+
*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.
358358

359359
For instructions on how to integrate Cmder with your IDE, please read our [Wiki section](https://github.com/cmderdev/cmder/wiki#cmder-integration).
360360

vendor/profile.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,14 @@ if ( $(Get-Command prompt).Definition -match 'PS \$\(\$executionContext.SessionS
221221
$lastSUCCESS = $?
222222
$realLastExitCode = $LastExitCode
223223

224+
# Emit OSC 133;D sequence for Windows Terminal shell integration
225+
# This marks the end of command execution with the exit code
226+
# Must be emitted before OSC 133;A (start of next prompt)
227+
# Only active in Windows Terminal ($env:WT_SESSION)
228+
if ($env:WT_SESSION) {
229+
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]133;D;$realLastExitCode$([char]7)"
230+
}
231+
224232
# Emit OSC 9;9 sequence for Windows Terminal directory tracking
225233
# This enables "Duplicate Tab" and "Split Pane" to preserve the working directory
226234
# Only active in Windows Terminal ($env:WT_SESSION) or ConEmu ($env:ConEmuPID)

0 commit comments

Comments
 (0)