microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.66k stars 28.68k forks source link

Expose shell integration command knowledge to extensions #145234

Closed Tyriar closed 1 month ago

Tyriar commented 2 years ago

Shell integration in the terminal could enable APIs like being able to listen to commands that run and get their output/exit code.

Rough example:

interface Terminal {
  executeCommand(command): Thenable<TerminalCommandResult>;
}
Tyriar commented 2 months ago

@whitequark no, this is only for when shell integration is enabled. There is the related proposal for buffer access which allows reading the buffer which would probably cover your use case. https://github.com/microsoft/vscode/issues/207504

whitequark commented 2 months ago

@Tyriar Thank you, this really helps!

itstreefam commented 1 month ago

I have a quick question. What is the difference between this API and vscode.proposed.terminalExecuteCommandEvent.d.ts? My current use case is grabbing the output from an executed command, and I am using vscode.proposed.terminalExecuteCommandEvent.d.ts to do so. I suppose we can also use read() from vscode.proposed.terminalShellIntegration.d.ts to read the output stream but feel free to correct me. I wonder which one would you think have a higher chance for public release. Before these two APIs I remembered having to work around with the old vscode.proposed.terminalDataWriteEvent.d.ts, so I truly appreciate the current more stable approaches you have made available. Thanks!

Tyriar commented 1 month ago

@itstreefam terminalExecuteCommandEvent is old and will be removed, terminalDataWriteEvent is unlikely to get finalized and may be replaced eventually with improvements upon terminalShellIntegration. terminalShellIntegration should be finalized very soon, I just need a fix a few bugs with it.

Tyriar commented 1 month ago

Plan: