Interface Terminal

Definition of the terminal emulator.

interface Terminal {
    creationOptions: Readonly<TerminalOptions | ExtensionTerminalOptions>;
    exitStatus: undefined | TerminalExitStatus;
    name: string;
    processId: Thenable<number>;
    shellIntegration: undefined | TerminalShellIntegration;
    state: TerminalState;
    dispose(): void;
    hide(): void;
    sendText(text, shouldExecute?): void;
    show(preserveFocus?): void;
}

Implemented by

Properties

creationOptions: Readonly<TerminalOptions | ExtensionTerminalOptions>

The object used to initialize the terminal, this is useful for example to detecting the shell type of when the terminal was not launched by this extension or for detecting what folder the shell was launched in.

exitStatus: undefined | TerminalExitStatus

The exit status of the terminal, this will be undefined while the terminal is active.

Example: Show a notification with the exit code when the terminal exits with a non-zero exit code.

window.onDidCloseTerminal(t => {
if (t.exitStatus && t.exitStatus.code) {
vscode.window.showInformationMessage(`Exit code: ${t.exitStatus.code}`);
}
});
name: string

Human readable representation of the terminal in the UI.

processId: Thenable<number>

Terminal id.

shellIntegration: undefined | TerminalShellIntegration

An object that contains shell integration-powered features for the terminal. This will always be undefined immediately after the terminal is created. Listen to window.onDidChangeTerminalShellIntegration to be notified when shell integration is activated for a terminal.

Note that this object may remain undefined if shell integation never activates. For example Command Prompt does not support shell integration and a user's shell setup could conflict with the automatic shell integration activation.

Stubbed

The current state of the Terminal.

Methods

  • Send text to the terminal.

    Parameters

    • text: string

      The text to send.

    • Optional shouldExecute: boolean

      Indicates that the text being sent should be executed rather than just inserted in the terminal. The character added is \r, independent from the platform (compared to platform specific in vscode). This defaults to true.

    Returns void

  • Show created terminal on the UI.

    Parameters

    • Optional preserveFocus: boolean

      in case true - set up focus on the terminal widget, otherwise show terminal without focus.

    Returns void