Basil Bourque
Basil Bourque

Reputation: 340118

How to associate types of files in Mac Finder to be opened by IntelliJ IDEA in "LightEdit" mode if I am a JetBrains Toolbox user?

IntelliJ IDEA 2020 can (finally!) simply open a file to be edited, without a project being involved. This is called LightEdit mode.

At this point in a JetBrains video, we see the host platform's file manager app opening a file via IntelliJ while noting that all such files should be opened using that same tool.

No "IntelliJ" application to choose

The problem for me is that I am a happy user of JetBrains Toolbox app to automatically install, upgrade, and open IntelliJ. So in my "Applications" folder on macOS, I have no "IntelliJ" application to choose in the Mac Finder when trying to open a file.

Is there some other way or trick to getting the Finder to know to open files with IntelliJ? And preferably with the latest version, as I believe Toolbox may keep around the older versions.

Basically, I am asking the same as this Question, How to make available “open this project in IntelliJ IDEA” option in Windows context menu, if IntelliJ IDEA has been installed via JetBrains Toolbox?, but for macOS instead of MS Windows. The Answer on that other Question is Windows-specific.

Upvotes: 11

Views: 1201

Answers (2)

Aurel Branzeanu
Aurel Branzeanu

Reputation: 622

Use the app's menu: IntelliJ IDEA -> Preferences -> Editor -> File Types

Then press the Associate File Types with IntelliJ IDEA button.

enter image description here

A window will open with file groups you could choose from, and then press the OK button, then Apply and another OK.

After this, a MacOS restart is required.

Upvotes: 6

yivi
yivi

Reputation: 47648

As a Toolbox user you still have access to the "generated shell scripts" (/usr/local/bin/idea, or things like /usr/local/bin/phpstorm, /usr/local/bin/pycharm, etc for individual applications).

But, these are shell scripts, and cannot be used for this because they lack the application identifiers needed by the OS for launching apps.

What you can do is wrap any of this with an Automator application. By wrapping the shell script directly, it should remain updated (since the shell script is itself a Toolbox generated wrapper that points to the latest installed version).

To do so:

  1. Open Automator and click on the "new document" button.
  2. Select "Application".
    enter image description here
  3. Add a "Run shell script" action from the library:
    enter image description here
  4. Change the "pass input" dropdown from "to stdin" to "as arguments".
  5. Create a script similar to this this (replace phpstorm with idea or whatever IDE you have installed):
    for file in "$@"
    do
        /usr/local/bin/phpstorm -e "$file"
    done
    
  6. Save the application somwhere, with a descriptive name:
    enter image description here

Once that one is saved, you'll be able to use it to launch files from Finder, or even set it as default for a file type:

enter image description here

Upvotes: 6

Related Questions