34

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!

  • 2
    Note: iTerm2's new release of Build 3.0.0 adds "Atom" to the list of options for the "Open with editor..." dropdown as pictured above. You'll find it now in Preferences under Profiles -> Advanced -> Semantic History. – pdobb Jun 3 '16 at 13:21
22

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).

  • 6
    Hi! Leaving the "-n" out from your suggestion makes it open in an existing window (which is what I prefer). Unfortunately this makes atom fail to recognize the column number (it goes to the correct line though). Any ideas on this? – Cyberwiz Feb 29 '16 at 15:17
  • Any chance you can add the solution for iTerm2 to your answer please!? Thanks! – Matthew Herbst Feb 3 '17 at 1:58
  • 1
    @MatthewHerbst Atom is an option in the 'Open with editor...' select list now. This answer is no longer useful. – tjmcewan Feb 3 '17 at 4:20
18

(I use this one. For some reason the iTerm option "Open with default app" doesn't work, but the command "$ open whatever" works like a charm, so I've just set that command.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.