Macos – iTerm command click to open with Atom

iterm2macos

I am trying to figure out how to change iTerm function when CMD+Clicking on a file in an iTerm window to have it open in my default editor, Atom.

Currently, the CMD+click function in iTerm opens files in Sublime. I have the function CMD+Click set to open with the default app (within iTerm preferences). I have also ensured that this file type is configured to always open with Atom (in the file's info screen from Finder).

If I click the file from finder, it opens with Atom, not sublime text. The only clue I have is that maybe iTerm won't recognize Atom as an editor. If I go to iTerm Preferences > Profiles > Advanced and change the CMD+Click to open with what Editor, only sublime 3 is available in the list of editors to choose from.

Any help would be appreciated!

Best Answer

Inside Atom, go to the Atom menu and choose Install Shell Commands. This ensures you can call Atom from iTerm.

In that same iTerm preferences screen, change the first select list to Run command... and paste the following into the text field that appears: /usr/local/bin/atom -n \1:\2. That tells the atom command line tool to open the clicked file (\1) at the line number specified (\2).

Related Question