Merge branch 'master' into development

This commit is contained in:
DRSDavidSoft
2025-11-08 13:55:51 +00:00
2 changed files with 35 additions and 0 deletions

View File

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

33
vendor/profile.ps1 vendored
View File

@@ -91,6 +91,24 @@ if (Get-Command -Name "vim" -ErrorAction SilentlyContinue) {
if (Get-Module PSReadline -ErrorAction "SilentlyContinue") {
Set-PSReadlineOption -ExtraPromptLineCount 1
# Add OSC 133;C support for Windows Terminal shell integration
# This marks the start of command output (emitted when Enter is pressed)
if ($env:WT_SESSION) {
Set-PSReadLineKeyHandler -Key Enter -ScriptBlock {
# Get the current command line
$line = $null
$cursor = $null
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor)
# Accept the line first
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
# Emit OSC 133;C sequence to mark start of command output
# This is written directly to the console after the command is accepted
[Console]::Write("$([char]27)]133;C$([char]7)")
}
}
}
# Pre-assign default prompt hooks so the first run of cmder gets a working prompt.
@@ -205,6 +223,14 @@ if ( $(Get-Command prompt).Definition -match 'PS \$\(\$executionContext.SessionS
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]27)]9;9;`"$($loc.ProviderPath)`"$([char]27)\"
}
# Emit OSC 133;A sequence for Windows Terminal shell integration
# This marks the start of the prompt
# Enables features like command navigation, selection, and visual separators
# Only active in Windows Terminal ($env:WT_SESSION)
if ($env:WT_SESSION) {
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]27)]133;A$([char]7)"
}
$host.UI.RawUI.WindowTitle = Microsoft.PowerShell.Management\Split-Path $pwd.ProviderPath -Leaf
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x200B)`r$([char]0x1B)[K"
if ($lastSUCCESS -or ($LastExitCode -ne 0)) {
@@ -213,6 +239,13 @@ if ( $(Get-Command prompt).Definition -match 'PS \$\(\$executionContext.SessionS
PrePrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline
CmderPrompt
PostPrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline
# Emit OSC 133;B sequence for Windows Terminal shell integration
# This marks the start of command input (after prompt, before user types)
if ($env:WT_SESSION) {
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]27)]133;B$([char]7)"
}
$global:LastExitCode = $realLastExitCode
return " "
}