Stream terminal output and process exit code from Plugin

We can create a terminal session and run a command using

TerminalToolWindowManager.getInstance(project).createNewSession()
ShellTerminalWidget.executeCommand(/*command*/)

Is there a way to stream the output of the executed command and get its exit code from a plugin?

Hello! At the moment it is only possible to get the current text of the terminal using com.intellij.terminal.JBTerminalWidget#getText(). You can get the instance of JBTerminalWidget using com.intellij.terminal.JBTerminalWidget#asJediTermWidget. But it will only work for the Classic Terminal.

We plan to add getText method to TerminalWidget to make it available for all terminal implementations, including Reworked one, in 2025.2. Please follow IJPL-192386.

Regarding getting the exit code - it will be possible once we publish the API for the Reworked Terminal. But we have no ETA at the moment.
Also, we will consider output streaming support.

Hello! I have an update about command execution feature: we plan to improve it in the scope of implementing public API for the Reworked Terminal: IJPL-193161.
ETA is 2025.3

1 Like

Great! Thanks for the updates.

Hello! We plan to release the Reworked Terminal API in the upcoming 2025.3 release.
It includes a long-awaited possibility of tracking command execution in the terminal.
Please read the announcement: Reworked Terminal API is available in 2025.3