Skip to content

How to do shell integration with OSC 133 B and use -PromptText? #5219

Open

Description

Prerequisites

  • Write a descriptive title.

Activity

  1. richardcox13 commented on Oct 4, 2026

    @richardcox13
    Author

    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?

  2. matteocoder commented on Oct 17, 2026

    @matteocoder

    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.

  3. richardcox13 commented on Oct 17, 2026

    @richardcox13
    Author

    matteocoder that is a decent workaround.

    And, of course, I need to RTFM more: I had never noticed -PromptText can take two strings! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-DocsIt's a documentation issue.Needs-Triage 🔍It's a new issue that core contributor team needs to triage.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions