Skip to content

Test: Terminal shell integration #141339

@Tyriar

Description

@Tyriar

Refs: #133084

Complexity: 5

Authors: @Tyriar, @meganrogge

Create Issue


The terminal now features "shell integration" with the opt-in setting terminal.integrated.enableShellIntegration. The basics of this feature is that it runs a script in your shell of choice and injects invisible sequences at key points to tell the terminal about certain things, like where the prompt, command, output starts and what the current working directory (cwd) is. Shell integration activates by injecting arguments into the profile while it is starting up, you can view these injected arguments by looking for terminalInstance#ctor in a trace log.

Since a shell script needs to be written on a shell-by-shell basis, only the following are currently supported:

  • Windows
    • pwsh (6+, not "Windows PowerShell")
  • Linux/macOS
    • pwsh
    • bash
    • zsh

Currently these new insights into what's happening within the shell are used in the following features:

  • New command: Run Recent Command, running this after a terminal command executed is the easiest way to tell if shell integration is working
    • This command has a button on the right to open the command's output in the editor
  • New command: Terminal: Go to Recent Directory
  • Current working directory detection on Windows (this only worked on non-Windows before), this drives the following:
    • The terminal.integrated.splitCwd setting
    • Links in the terminal are resolved relatively against the current working directory
  • Clicking links in the terminal now resolve the links relatively to whatever cwd the command they're contained within. For example if you cd into a new directory, any links clicked below that will resolve against the new directory and any above that will use the old directory.
  • The old commands Select/Scroll to Previous/Next Command now use shell integration if it's available, otherwise they fallback to the old mechanism (which assumed it was a command anytime you press enter when the cursor was in the 3rd column or beyond)

Test the feature on each of the shells assigned to your platform. Some things to try:

  • Does shell integration activate?
  • Install a special prompt and see if shell integration still works, if not does it fail gracefully?
  • Test the new features above
  • Does the hover for your terminal tab show information about shell integration?
  • Turn off shell integration and try the features, do they work as expected?

Here are some of the main limitations you may hit while testing:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions