You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to do shell integration with OSC 133 B and use -PromptText? #5219
The shell integration allows Windows Terminal's copy command and copy output to correctly select the correct text by outputting various escape sequences. The significant one is OSC 133 B ST ("e]133;Be\") (aka "FTCS_COMMAND_START") to mark the end of the prompt, start of the command output.
This works, until PSReadline highlights the end of my prompt for an erroneous/incomplete command (eg. an unmatched quote). The highlight works, but either my prompt is messed up (when I include the OSC sequence in the string passed to -PromptText, or the final part of my prompt is included in the selection if I do not include the escape sequence.
As the visible text of my prompt ends with "u{e0b0} "that is what I have been passing to-PromptText` but after a highlight/un-highlight cycle those characters are treated as part of the command.
If I do include the OSC sequence then earlier text in the prompt is overwritten (without any pattern I can see).
How do I both correctly have "e]133;Be\" written at the end of my prompt for the terminal integration and have the Powerline Chevron at the end of my prompt highlight with invalid input?
Richard Cox (@richardcox13) I have been struggling with the very same issue for a long time, and I have concluded that there is no perfectly clean solution as of now.
Terminal integration assumes that the prompt text will remain static once it has been written to the console. However, PromptText nullifies that assumption by design, since it modifies the prompt when you're typing your command. The two approaches are at odds with each other.
A hacky workaround is to write the end of your prompt as follows:
"PS>`e]133;B$([char]07) "
and then have -PromptText ' ','!'. This way, PromptText is only going to touch the single whitespace character, which comes after the prompt end sequence.
Activity
richardcox13 commentedon Oct 4, 2026
I am trying to have both PSReadLine highlight the end of my prompt when input is incomplete and make use of Windows Terminal shell integration (see https://devblogs.microsoft.com/commandline/shell-integration-in-the-windows-terminal/#how-does-this-work).
The shell integration allows Windows Terminal's copy command and copy output to correctly select the correct text by outputting various escape sequences. The significant one is
OSC 133 B ST("e]133;Be\") (aka "FTCS_COMMAND_START") to mark the end of the prompt, start of the command output.This works, until PSReadline highlights the end of my prompt for an erroneous/incomplete command (eg. an unmatched quote). The highlight works, but either my prompt is messed up (when I include the OSC sequence in the string passed to
-PromptText, or the final part of my prompt is included in the selection if I do not include the escape sequence.As the visible text of my prompt ends with
"u{e0b0} "that is what I have been passing to-PromptText` but after a highlight/un-highlight cycle those characters are treated as part of the command.If I do include the OSC sequence then earlier text in the prompt is overwritten (without any pattern I can see).
How do I both correctly have
"e]133;Be\"written at the end of my prompt for the terminal integration and have the Powerline Chevron at the end of my prompt highlight with invalid input?matteocoder commentedon Oct 17, 2026
Richard Cox (@richardcox13) I have been struggling with the very same issue for a long time, and I have concluded that there is no perfectly clean solution as of now.
Terminal integration assumes that the prompt text will remain static once it has been written to the console. However,
PromptTextnullifies that assumption by design, since it modifies the prompt when you're typing your command. The two approaches are at odds with each other.A hacky workaround is to write the end of your prompt as follows:
and then have
-PromptText ' ','!'. This way,PromptTextis only going to touch the single whitespace character, which comes after the prompt end sequence.richardcox13 commentedon Oct 17, 2026
matteocoder that is a decent workaround.
And, of course, I need to RTFM more: I had never noticed
-PromptTextcan take two strings! 😄