Open files from iTerm2 with RubyMine on MacOS

Want to command left click on files in iTerm2 and have them open in RubyMine (or whichever JetBrains app you like?

CloudApp — Not Found

In RubyMine, go to menu: Tools -> Create Command-line Launcher...

Below assumes that you use the default:

/usr/local/bin/mine

Open iTerm preferences -> Profiles -> Advanced -> Semantic History

Select Run command and paste:

/usr/local/bin/mine \5 --line \2 \1