Skip to content

[Feature request] Add OSC 9;9 support for PowerShell prompt in Cmder to enable Windows Terminal duplicate/split in same directory #3025

@DRSDavidSoft

Description

@DRSDavidSoft

Suggestion

Implement OSC 9;9 support in Cmder's PowerShell prompt so Windows Terminal can duplicate and split tabs/panes in the same working directory, matching the recent fix for cmd.exe/Clink and following Microsoft's published guidance.

Use case

Cmder's cmd.exe integration now emits OSC 9;9 via Clink for Windows Terminal, enabling 'Duplicate Tab' and 'Split Pane' to preserve the working directory. PowerShell users can manually add OSC 9;9 emission to their prompt (per MicrosoftDocs/terminal), but Cmder's PowerShell experience should work seamlessly out of the box.

Example implementation:

This can be integrated into the existing profile.ps1 script that Cmder uses.

function prompt {
  $loc = $executionContext.SessionState.Path.CurrentLocation
  $out = ""
  if ($env:WT_SESSION -and $loc.Provider.Name -eq "FileSystem") {
    $out += "$([char]27)]9;9;`"$($loc.ProviderPath)`"$([char]27)\"
  }
  $out += "PS $loc$('>' * ($nestedPromptLevel + 1)) "
  return $out
}

If posh-git is present, wrap $GitPromptScriptBlock and add OSC 9;9 as in Microsoft Docs.

Ensure the change is non-invasive and only active in Windows Terminal and ConEmu (detect what terminal we're running on, using environment variables).

Extra info/examples/attachments

Checklist:

  • Add OSC 9;9 emission for PowerShell in Cmder’s default profile.
  • Gate emission behind $env:WT_SESSION or the equivalent for ConEmu.
  • Preserve user customizations and compatibility with posh-git/Starship (if any).
  • Document the change in the PR.

Checklist

  • I have read the documentation and made sure this feature doesn't already exist.
  • I have searched for similar issues and found none that describe my feature request.

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions