Skip to content

Add OSC 133 shell integration sequences for Windows Terminal PowerShell support#3041

Merged
DRSDavidSoft merged 2 commits intomasterfrom
copilot/add-terminal-codes-support
Nov 8, 2025
Merged

Add OSC 133 shell integration sequences for Windows Terminal PowerShell support#3041
DRSDavidSoft merged 2 commits intomasterfrom
copilot/add-terminal-codes-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 8, 2025

Windows Terminal supports OSC 133 escape sequences (\x1b]133;A\a, \x1b]133;B\a, \x1b]133;C\a) for shell integration, enabling command navigation, selection, and visual separators. Cmder already supports OSC 9;9 for directory tracking—this adds OSC 133 support for PowerShell sessions.

Changes

vendor/profile.ps1

  • OSC 133;A (line 231): Emitted before prompt rendering to mark prompt start
  • OSC 133;B (line 246): Emitted after prompt to mark command input start
  • OSC 133;C (line 109): Emitted via PSReadLine Enter handler to mark command output start

README.md

  • Documented shell integration support alongside existing OSC 9;9 documentation

Implementation

All sequences conditionally emit only when $env:WT_SESSION is set, ensuring no interference with ConEmu or other terminals:

# OSC 133;A - marks start of prompt
if ($env:WT_SESSION) {
    Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]27)]133;A$([char]7)"
}

# OSC 133;C - marks start of command output (via PSReadLine)
if ($env:WT_SESSION) {
    Set-PSReadLineKeyHandler -Key Enter -ScriptBlock {
        [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
        [Console]::Write("$([char]27)]133;C$([char]7)")
    }
}

Follows existing OSC 9;9 pattern for consistency.

Original prompt

Why Windows Terminal support these codes, what they are, and do we need to add them in Cmder's PowerShell profile as well?

"\x1b]133;A\a"
"\x1b]133;B\a"
"\x1b]133;C\a"


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…ll support

Co-authored-by: DRSDavidSoft <4673812+DRSDavidSoft@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for escape codes in Cmder PowerShell profile Add OSC 133 shell integration sequences for Windows Terminal PowerShell support Nov 8, 2025
Copilot AI requested a review from DRSDavidSoft November 8, 2025 13:47
@DRSDavidSoft DRSDavidSoft marked this pull request as ready for review November 8, 2025 13:54
@DRSDavidSoft DRSDavidSoft merged commit f9d402d into master Nov 8, 2025
6 checks passed
@DRSDavidSoft DRSDavidSoft deleted the copilot/add-terminal-codes-support branch November 8, 2025 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants