Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enumerate terminals in extensions API

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?

like image 914
Richard Cook Avatar asked Jan 08 '18 17:01

Richard Cook


1 Answers

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)
like image 167
Matt Bierner Avatar answered Sep 24 '22 23:09

Matt Bierner