Hi,
I am in my initial phases of writing IntelliJ plugin. My requirement is I want to access the most recent command and its response (if any) from the terminal and also, I need to execute the commands in terminal.
I read that with the help Terminal plugin we can achieve the above.
So I tried to add the terminal dependency in my project like below.
in gradle.properties
Configuration cache state could not be cached: field `provider` of `org.gradle.internal.serialize.codecs.core.ProviderBackedFileCollectionSpec` bean found in field `element` of `java.util.Collections$SingletonList` bean found in field `elements` of `org.gradle.internal.serialize.codecs.core.ResolutionBackedFileCollectionSpec` bean found in field `__classpathSnapshot__` of `org.jetbrains.kotlin.gradle.tasks.KotlinCompile$ClasspathSnapshotProperties` bean found in field `__classpathSnapshotProperties__` of task `:compileKotlin` of type `org.jetbrains.kotlin.gradle.tasks.KotlinCompile`: error writing value of type 'org.gradle.api.internal.provider.DefaultProvider'
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find com.jetbrains.plugins:org.jetbrains.plugins.terminal:.
Required by:
root project :
Note: I am using intelliJ community edition
if the terminal plugin is not available in community Edition, what is the alternate for this and How to achieve this requirement ?
Thank you for your response. My primary objective is to execute a terminal command directly within the user’s IDE—specifically, opening the Run or Terminal prompt inside the IDE (not in an external window) and executing the command there. Is this kind of action supported? If so, do you have any sample code that demonstrates how to achieve it?
I have a similar requirement as you. And stuck in get multi-line responses in terminal because the window may scroll, so ShellTerminalWidget.terminalTextBuffer is hard to use. Do you have a solution for this?
Hi shihanmeng,
I don’t have any solution to access the most recent command only. But we can use JBTerminalWidget.getText() to get the entire terminal content.
Hi Tomer,
Yes, ShellTerminalWidget.executeCommand will support to execute a terminal command directly within the user’s IDE.
or else we can use jbTerminalWidget.getTtyConnector().write(command) to write the command in terminal and providing additional lineSeparator (like enter) to execute the command, which doesn’t requires to add terminal plugin dependency.
If the terminal is not already opened, we need to get the terminal from ToolWindow and show it using toolwindow.show(), before executing command.