Reputation: 33089
I know how to create a new terminal from a VSCode extension using the vscode.window.createTerminal
method. This method returns a reference to the terminal so that I can subsequently interact with it, for example, by sending strings to it etc.
I would really like to be able to interact with existing terminals in VSCode but cannot find any APIs to do this. Is it possible to enumerate all open integrated terminals in VSCode?
Upvotes: 8
Views: 315
Reputation: 65313
VS Code 1.26 added window.terminals
. This readonly array allows you to access all terminals
There is also:
window.activeTerminal
- Currently active terminal or undefined if none.window.onDidChangeActiveTerminal
- Event fired when the active terminal changes window.onDidOpenTerminal
- Event fired when a new terminal is created (either by an extension or by the user)Upvotes: 2