Creates a new SSH terminal session for the given device.
The device configuration to connect to.
The extension context for secret storage access.
OptionalinitialPath: stringOptional working directory to open on connect.
ReadonlyonAn event that when fired will signal that the pty is closed and dispose of the terminal.
Events fired before Pseudoterminal.open is called will be be ignored.
A number can be used to provide an exit code for the terminal. Exit codes must be
positive and a non-zero exit codes signals failure which shows a notification for a
regular terminal and allows dependent tasks to proceed when used with the
CustomExecution API.
Example: Exit the terminal when "y" is pressed, otherwise show a notification.
const writeEmitter = new vscode.EventEmitter<string>();
const closeEmitter = new vscode.EventEmitter<void>();
const pty: vscode.Pseudoterminal = {
onDidWrite: writeEmitter.event,
onDidClose: closeEmitter.event,
open: () => writeEmitter.fire('Press y to exit successfully'),
close: () => {},
handleInput: data => {
if (data !== 'y') {
vscode.window.showInformationMessage('Something went wrong');
}
closeEmitter.fire();
}
};
const terminal = vscode.window.createTerminal({ name: 'Exit example', pty });
terminal.show(true);
ReadonlyonAn event that when fired will write data to the terminal. Unlike Terminal.sendText which sends text to the underlying child pseudo-device (the child), this will write the text to parent pseudo-device (the terminal itself).
Note writing \n will just move the cursor down 1 row, you need to write \r as well
to move the cursor to the left-most cell.
Events fired before Pseudoterminal.open is called will be be ignored.
Example: Write red text to the terminal
const writeEmitter = new vscode.EventEmitter<string>();
const pty: vscode.Pseudoterminal = {
onDidWrite: writeEmitter.event,
open: () => writeEmitter.fire('\x1b[31mHello world\x1b[0m'),
close: () => {}
};
vscode.window.createTerminal({ name: 'My terminal', pty });
Example: Move the cursor to the 10th row and 20th column and write an asterisk
writeEmitter.fire('\x1b[10;20H*');
Closes the terminal session and releases resources.
Handles user input by forwarding it to the remote shell.
Input text entered by the user.
Opens the pseudoterminal and initiates the SSH connection.
OptionalinitialDimensions: TerminalDimensionsTerminal dimensions supplied by VS Code.
Updates the remote shell when the terminal dimensions change.
The new terminal dimensions.
Pseudoterminal that proxies input/output to an SSH shell session.