How to open Atom editor from command line in OS X?
I have the Atom editor and was wondering how you can open a file or folder from the terminal in Atom. I am using a Mac. I am looking for a way to do this:
atom . (opens folder) atom file.js (opens file) atom (opens editor)
Is this possible and how do I set it up?
When Atom installs it automatically creates a symlink in your /usr/local/bin. However in case it hasn't, you can create it yourself on your Mac
ln -s /Applications/Atom.app/Contents/Resources/app/atom.sh /usr/local/bin/atom
Now you can use
atom folder_name to open a folder and
atom file_name to open a file. Hope this helps.
With the Atom editor open, in the menu bar:
Click Atom >> Install Shell Commands
You should expect to see:
Potentially restart your terminal. (I did just out of habit, not sure if you need to)
Read more... Read less...
Roll your own with @Clockworks solution, or in Atom, choose the menu option Atom > Install Shell Commands. This creates two symlinks in
apm -> /Applications/Atom.app/Contents/Resources/app/apm/node_modules/.bin/apm atom -> /Applications/Atom.app/Contents/Resources/app/atom.sh
atom command lets you do exactly what you're asking.
apmis the command line package manager.
For Windows 7 x64 with default Atom installation add this to your PATH
and restart any running consoles
(if you don't find Atom there - right-click Atom icon and navigate to Target)
The symlink solution for this stopped working for me in zsh today. I ended up creating an alias in my
.zshrc file instead:
alias atom='sh /Applications/Atom.app/Contents/Resources/app/atom.sh'
On macOS you can add it to your
alias atom='open -a "Atom"'
and from terminal just call
Open the application by name:
open -a 'Atom' FILENAME