Execute command in the terminal from plugin action
Answered
Hello.
I`m developing a plugin for simplify some routine commands executing by clicking on action.
Now I`m using com.intellij.execution.configurations.GeneralCommandLine class for executing and it`s works fine. But would be great to open the terminal panel in idea and execute command in it.
Is it possible from plugin code?
Please sign in to leave a comment.
If you have `JBTerminalWidget` instance, you can just write command to the input stream:
`widget.getTtyConnector().write("echo foo")`
Above code works for me.
Is there a way to determine the current shell type (e.g., PowerShell or Bash)?
I’m encountering a problem when writing a command with multiple lines.
If I use

\n
to break lines, they are produced in reverse order in PowerShell but appear correct in other shells.(Powershell)
I was tried to write line by line as well
If I use
\r\n
to break lines, it works for PowerShell but causes issues in other shells.(Powershell works but with redudant new lines at the end)
I’m trying to detect the shell type to determine the appropriate line break to use.
Do you have any suggestions for resolving this issue?
I am unable to reference
TerminalView
. What should I do? The version set in IntelliJ Platform is 2.1.0.