Search code examples
javaintellij-ideajetbrains-ideintellij-pluginjetbrains-gateway

In JetBrains plugin development, how to execute command in the terminal from plugin action with Gateway


I am new to plugin development for JetBrains and would like to know how I can execute a command in the terminal with JetBrains Gateway.

I've tried like this:

var shellTerminalWidget = TerminalView.getInstance(project).createLocalShellWidget(currentWorkspacePath, "NewTab");
shellTerminalWidget.executeCommand(command);

It works well when I test locally. However, when I use JetBrains Gateway and install this plugin on the host, it doesn't work any longer, and I can't find any exceptions in the log.

Is there any difference when using Gateway?


Solution

  • Right now such code creates an invisible terminal which should be shared explicitly:

    BackendTerminalManager.getInstance(project).shareTerminal(...)
    

    But we are going to fix in and automatically share all created local terminals in remoteDev, feel free to trach this issue:

    https://youtrack.jetbrains.com/issue/CWM-6928