iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
👻

How to Automatically Run Commands When Opening a Project in IntelliJ IDEA

に公開

I use this to do things like start a database when opening a specific project.

Environment

IntelliJ IDEA Ultimate Edition 2023.1.2

Steps

(1) Open Settings.

(2) Open [Tools] - [Startup Tasks] in Settings.

Screenshot 2023-05-26 8.16.11.png

The menu layout often changes with version updates, so it might be better to search using the keyword "Startup."

(3) Click the [+] at the top left of the screen -> [Add New Configuration] -> Select [Shell Script].

Screenshot 2023-05-26 8.18.44.png

(4) Enter the following:

  • Name: Any name
  • Execute: Script text
  • Script text: The command you want to run (e.g., starting a DB with docker compose)
  • Working directory: Any directory
  • Environment variables: Set if necessary
  • Execute in terminal: Check the box

Screenshot 2023-05-26 8.22.30.png

By selecting [Script file] in [Execute], you can also run a shell script written in a file.

(5) Click [OK].

Discussion