-->

In IntelliJ IDEA, how can I create a key binding t

2020-08-27 05:03发布

问题:

In IntelliJ IDEA, how can I create a key binding that executes a shell script with the current file as a parameter?

For exanmple, if I am in a test file (entity.spec.js), I want to save and hit a key binding to trigger a shell script with that file as the parameter:

./run_test.sh /full/path/to/entity.spec.js

Any idea how to do that?

回答1:

You can do it using the External Tools. Then you can assign a keyboard shortcut to your tool in Settings | Keymap.

Please note that you should specify your shell interpreter as a Program for the external tool (such as /bin/bash) and pass your script path and the file name as Parameters. Use Insert Macro button to add a macro for the current editor file path.