Search code examples
intellij-ideawebstorm

Add a custom command (with a custom icon)


Is it possible in IntelliJ/WebStorm to add a custom icon somewhere in a toolbar that runs a custom command, e.g. CLI?

If yes, is it also possible to add this in the projects .idea so that my team members also have this icon without any configuration?

My goal is to add some custom Git commands.


Solution

  • I'm not sure about icons (never used them myself) .. but as far as I'm aware this would not be easily to copy it over (custom toolbar actions) as it would be an IDE-wide setting which you cannot copy as separate file (it will be a part of actual IDE customisation config -- hence uniqueness for each user). Therefore tool buttons are rather user-specific and not recommended way if you want to share this stuff or update it in a future with not much hassle (at very least to have such possibility).


    Instead you could just use External Tools functionality for executing your custom CLI commands -- this will also be an IDE-wide setting but each group is stored in separate file.. so others will have to copy such file into IDE config folder. Each such tool can then be accesses via context menus (it has 4 places where such commands can be placed: Tools menu and 3 context menus).


    Another alternative (that could be shared as part of the actual project) is to code all your custom CLI commands as Gulp/Grunt/NPM script tasks and execute them that way. Since such files are usually placed in project root (or subfolder) .. they can be easily shared via VCS.

    All tasks/scripts are loaded from actual task definition files (package.json/gulpfile.js/etc) .. so they are not stored inside .idea subfolder. But you can create Run/Debug Configurations (to quickly run specific task with possible custom parameters etc) .. and such stuff is placed inside .idea (make sure to mark them as "Shared" .. otherwise they will be stored inside user-specific and not-VCS-shareable workspace.xml file rather than individual files).