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.

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].

(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

By selecting [Script file] in [Execute], you can also run a shell script written in a file.
(5) Click [OK].
Discussion