Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalize shell integration sequences #155639

Closed
7 tasks done
Tyriar opened this issue Jul 19, 2022 · 5 comments
Closed
7 tasks done

Finalize shell integration sequences #155639

Tyriar opened this issue Jul 19, 2022 · 5 comments
Assignees
Labels
debt Code quality issues terminal-shell-integration Shell integration, command decorations, etc.
Milestone

Comments

@Tyriar
Copy link
Member

Tyriar commented Jul 19, 2022

This issue tracks cleaning up the shell integration sequences, documenting and encouraging third parties to use the sequences.

Possible users:

Some things to look into:

  • The continuation (F, G) and right prompt (H, I) sequences are not thoroughly tested, we should investigate whether we need these at all considering.
  • Review and document all known properties (P)?
    • Should we support one of the common cwd properties instead of roll our own? Hostname and different sequences for different operating systems were some of the complications here.
    • How should cwds be treated in ssh where VS Code's shell integration is installed?
    • The Task should should be more generic
  • Improve command line (E) serialization of special characters
  • Should 633 A-D be removed in favor of 133 A-D? p10k works in a degraded state when sending these, if it also sent E (and P?) would it be fully functional?

The current sequences are lightly documented in code here:

/**
* VS Code-specific shell integration sequences. Some of these are based on common alternatives like
* those pioneered in FinalTerm. The decision to move to entirely custom sequences was to try to
* improve reliability and prevent the possibility of applications confusing the terminal.
*/
const enum VSCodeOscPt {
/**
* The start of the prompt, this is expected to always appear at the start of a line.
* Based on FinalTerm's `OSC 133 ; A ST`.
*/
PromptStart = 'A',
/**
* The start of a command, ie. where the user inputs their command.
* Based on FinalTerm's `OSC 133 ; B ST`.
*/
CommandStart = 'B',
/**
* Sent just before the command output begins.
* Based on FinalTerm's `OSC 133 ; C ST`.
*/
CommandExecuted = 'C',
/**
* Sent just after a command has finished. The exit code is optional, when not specified it
* means no command was run (ie. enter on empty prompt or ctrl+c).
* Based on FinalTerm's `OSC 133 ; D [; <ExitCode>] ST`.
*/
CommandFinished = 'D',
/**
* Explicitly set the command line. This helps workaround problems with conpty not having a
* passthrough mode by providing an option on Windows to send the command that was run. With
* this sequence there's no need for the guessing based on the unreliable cursor positions that
* would otherwise be required.
*/
CommandLine = 'E',
/**
* Similar to prompt start but for line continuations.
*/
ContinuationStart = 'F',
/**
* Similar to command start but for line continuations.
*/
ContinuationEnd = 'G',
/**
* The start of the right prompt.
*/
RightPromptStart = 'H',
/**
* The end of the right prompt.
*/
RightPromptEnd = 'I',
/**
* Set an arbitrary property: `OSC 633 ; P ; <Property>=<Value> ST`, only known properties will
* be handled.
*/
Property = 'P'
}

@Tyriar
Copy link
Member Author

Tyriar commented Aug 8, 2022

PR is out for the VS Code side of this #157571

Here are the answers to the questions above:

  • The continuation (F, G) and right prompt (H, I) sequences are not thoroughly tested, we should investigate whether we need these at all considering.
    • These are no being finalized as they're barely used right now
  • Review and document all known properties (P)?
    • IsWindows and Cwd will be finalized only
  • Should we support one of the common cwd properties instead of roll our own? Hostname and different sequences for different operating systems were some of the complications here.
  • How should cwds be treated in ssh where VS Code's shell integration is installed?
    • This is a problem we can solve in time with backwards compatible changes
  • The Task should should be more generic
    • This will not be finalized
  • Improve command line (E) serialization of special characters
    • Moving to \xAB hex representation as most developers are aware of
  • Should 633 A-D be removed in favor of 133 A-D? p10k works in a degraded state when sending these, if it also sent E (and P?) would it be fully functional?

@andyleejordan
Copy link
Member

Thanks for doing this @Tyriar!

@pfitzseb
Copy link
Contributor

pfitzseb commented Aug 9, 2022

#15751 makes it sounds like all ASCII chars should be replaced by their char codes, but that's only strictly necessary for '\n' and ';', plus escaping of backslashes. Would it make sense to specify that in the docs?

@Tyriar
Copy link
Member Author

Tyriar commented Aug 9, 2022

@pfitzseb will clarify 👍

Tyriar added a commit that referenced this issue Aug 9, 2022
@Tyriar
Copy link
Member Author

Tyriar commented Aug 9, 2022

With the 2 PRs I'll call this closed, still open to feedback. The website docs will be covered in microsoft/vscode-docs#4809, until then the in code comments are the main documentation.

@Tyriar Tyriar closed this as completed Aug 9, 2022
joyceerhl pushed a commit that referenced this issue Aug 10, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Sep 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debt Code quality issues terminal-shell-integration Shell integration, command decorations, etc.
Projects
None yet
Development

No branches or pull requests

4 participants