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?
This question is related to
macos
command-line-interface
atom-editor
I am on mingw bash, so I have created ~.profile file with following: alias atom='~/AppData/Local/atom/bin/atom'
Upgrading Atom appears to break command line functionality on the occasion. Looks like in my case it created two versions of the application instead of overwriting them. Occurs because the new file structure doesn't match file paths created by "Atom -> Install Shell Commands". In order fix the issue you'll need to do the following.
After that everything should work just like it did before. Hopefully this saves someone 30 minutes of poking around.
I had the same issue which I resolved by first moving Atom.app from downloads to Applications. Then under Atom's menu options, I selected "Install Shell Commands".
For Windows10 and new release of atom i solved the problem by adding in my ENV VARIABLE on the "PATH" row
%USERPROFILE%\AppData\Local\atom\bin
On macOS you can add it to your ~/.bash_profile
as
alias atom='open -a "Atom"'
and from terminal just call
atom filename.whatever
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)
I had problems due to atom being unable to write its logfile when starting from the commandline. This cured it.
sudo chmod 777 ~/.atom/nohup.out
With conemu on windows 10 I couldn't call atom
from console even after I added %USERPROFILE%\AppData\Local\atom\bin
to PATH in environment variables. I just added
alias atom="C:/Users/me/AppData/local/atom/app-1.12.7/atom"
to my .bashrc
file.
Open the application by name:
open -a 'Atom' FILENAME
Iv'e noticed this recently with all new macs here at my office. Atom will be installed via an image for the developers but we found the Atom is never in the Application folder.
When doing a ls on the /usr/local/bin folder the path for atom will show something like "/private/var/folders/cs" . To resolve this, we just located atom.app and copied it into the application folder, then ran the system link commands provided by nwinkler which resoled the issue. Developers can now open atom from the command line with "atom" or open the current projects from their working director with "atom ."
Roll your own with @Clockworks solution, or in Atom, choose the menu option Atom > Install Shell Commands. This creates two symlinks in /usr/local/bin
apm -> /Applications/Atom.app/Contents/Resources/app/apm/node_modules/.bin/apm
atom -> /Applications/Atom.app/Contents/Resources/app/atom.sh
The atom
command lets you do exactly what you're asking. apm
is the command line package manager.
In addition to @sbedulin (Greeting, lovely Windows users!)
The general path on Windows should be
%USERPROFILE%\AppData\Local\atom\bin
If you are using a bash emulator like babun. You'd better checkout the shell files, which only available in the real app folders
/c/User/<username>/AppData/Local/atom/app-<version>/resources/cli/apm.sh # or atom.sh
add path(:/usr/local/bin/) in profile.
mac: $home/.bash_profile
export PATH=$GOPATH/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:$PATH
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'
Another simple solution is to add /usr/local/bin to your PATH. I had the same issue, I installed shell commands (see shaheenery's response) the symlinks already existed and pointing to the correct destination (see thomax's response), however I would still get 'not found'. I'm using Korn Shell btw.
Here's what I did:
$ emacs ~/.kshrc
)export PATH="/usr/local/bin:${PATH}"
source ~/.profile
$ atom -h
Source: Stackoverflow.com