- Make sure IntelliJ IDEA is running.
- On the main menu, choose
Tools
>Create Command-line Launcher
. The dialog box Create Launcher Script opens, with the suggested path and name of the launcher script. You can accept default, or specify your own path. - Make notice of it, as you'll need it later. Outside of IntelliJ IDEA, add the path and name of the launcher script to your path.
- Specify the location of the IntelliJ IDEA executable in the Path system environment variable. In this case, you will be able to invoke the IntelliJ IDEA executable and other IntelliJ IDEA commands from any directory.
For more information, visit https://www.jetbrains.com/help/idea/2016.2/running-intellij-idea-as-a-diff-or-merge-command-line-tool.html
- In windows 10, if you face some warning like “Could not open/create prefs root node …” Ref: http://stackoverflow.com/questions/16428098/groovy-shell-warning-could-not-open-create-prefs-root-node Thanks to @SanthoshDhandapani for this.
The problem on macOS is that the shell script generated by JetBrains Toolbox looks like this:
However, if you
man open
, you'll see that the additional flag-W
is required:Solution
Caveat: The JetBrains toolbox will likely clobber changes to the generated script, so perhaps instead make a new one named like
idea-wait
/intellij-wait
and replace the name aftercmd =
in the config below. Alternatively again, you could inline entireopen -Wna …
command. This would make your.gitconfig
non-portable, but would remove the need to muck around with the script files.Add the additional
-W
flag to the script. It's also not a bad idea to useexec
so thatsh
doesn't sit in the way of signals:Which allows the following portable and correctly-quoted
.gitconfig
to work:Note also that if you have
realpath
available (viabrew install coreutils
), those awkward\"$(cd \"$(dirname…)\"…)/$(basename …)\"
lines can just be replaced by e.g.\"$(realpath \"${LOCAL}\")\"
.