Sammy Kumar
Sammy Kumar

Reputation: 121

How can I execute a terminal command when opening IntelliJ Project?

Not even sure if this possible with IntelliJ but I'd like to tie the vagrant up command to run automatically when I open an IntelliJ project. I've scoured the settings but haven't been able to find anything that gives me this functionality.

Upvotes: 0

Views: 539

Answers (1)

vikingsteve
vikingsteve

Reputation: 40398

You can write a plugin.

https://www.jetbrains.com/help/idea/plugin-development-guidelines.html

Define an application component in the plugin.xml

<application-components>
  <component>
    <implementation-class>com.steve.plugins.recentprojects.RecentProjects</implementation-class>
  </component>
</application-components>

And then you implement ApplicationComponent, which defines these methods in a parent interface:

public interface BaseComponent extends com.intellij.openapi.components.NamedComponent {
    default void initComponent() { /* compiled code */ }
    default void disposeComponent() { /* compiled code */ }
}

It seems like initComponent() can be a nice place to insert a function to start vagrant.

Alternatively... externalise the startup, write a script that starts vagrant and then starts intellij...

Upvotes: 2

Related Questions