Open file/project from terminal / command line


#1

As with TextMate or Sublime Text, you could run mate . or subl . respectively and open the current directory as a project in your editor.

Would be nice!


#2

I believe you can do this by typing atom from a directory.


#3

Correct, if you just do atom within the directory it will open it.


#4

Ah! Beautiful. Thanks!


#5

Do you need to create your own alias for this? After downloading the atom zip file, I extracted it to my Applications directory. Atom is working but atom isn’t “automatically” a command I can run?

Any help would be appreciated.
Thanks.


#6

Open up the command palette (⇧⌘P if you haven’t figured that out yet) and run the command called Install Shell Commands


#7

@rpowelll thanks for this!


#8

CLI support from Atom.app/Contents/MacOS/Atom is great but not as Sublime.

The feature I like the most is subl -a .
But other features can be implemented like:

  -n or --new-window:  Open a new window
  -b or --background:  Don't activate the application

I never tried, but, is Atom supporting Git message editing ?


#9

Yes, I set my global Git config to use atom -w for my editor and it works just fine.


#10

There is also command line --help:

atom --help
Atom Editor v0.80.0

Usage: atom [options] [file …]

Options:
-d, --dev Run in development mode. [boolean]
-f, --foreground Keep the browser process in the foreground. [boolean]
-h, --help Print this usage message. [boolean]
-l, --log-file Log all output to file. [string]
-n, --new-window Open a new window. [boolean]
-s, --spec-directory Set the spec directory (default: Atom’s spec directory). [string]
-t, --test Run the specified specs and exit with error code on failures. [boolean]
-v, --version Print the version. [boolean]
-w, --wait Wait for window to be closed before returning. [boolean]


#11

For some reason, shell commands weren’t automatically installed when I installed Atom recently. If this happens to you, see rpowelll’s response.


#12

I did not have to install Shell Commands just now. On a Mac OS X install, downloaded Atom, dragged it to my Applications directory, opened it once, quit, typed atom in the terminal, and voìla! Atom opened…


#13

I was reading the Atom Flight Manual and I skimmed over this crucial information.

Atom Flight Manual / 1.3 Atom Basics / Opening a File

Another way to open a file in Atom is from the command line. In the Atom menu bar there is a command named “Install Shell Commands” which installs a new command in your Terminal called atom. You can run this with a file path to open up that file in Atom.

It’s not installed by default. Clicking this link in the main Atom menu will install it.


Mac client suddenly stopped working
#14

Did something change with the command line commands recently? I used to be able to open the directory I was in by simply typing atom, but now I have to add a dot after the word atom to open the directory. Simply typing atom now opens the Atom editor, but with the last thing I had open before quitting it previously.


#15

Yes, this change in behavior was listed in the v0.199.0 release notes:


#16

It was a little confusing to discover what I have to do for opening folder in Atom from terminal after upgrading to 0.199.0 …


#17

Just so its clear to anyone else this is now atom . from command line since the update mentioned above.


#18

Try adding it to atom to your path


#19

I have Atom and my Terminal on different desktops on OS X. When I use atom FILENAME it opens a new Atom window on the same desktop where the Terminal is instead of appending a new tab to the already open Atom instance on the other desktop. Any change to get this behavior changed?


#20

As mentioned by @peterkraume the behaviour of always opening a new window is quite irritating, coming from Sublime where everything uses the same window by default.

To clarify from @peterkraume’s description of the problem, atom filename.txt always opens a new window, instead of using the existing one. The new window also doesn’t remember the open project, so you start with a blank slate.

I expected it to just open the file in a new tab in the existing window.

If there was a setting or package I could install to change this behaviour (or even a command-line flag I could alias in) that’d be fine. Any suggestions?