How to open Atom editor from command line in OS X?

2019-01-16 00:16发布

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?

17条回答
Ridiculous、
2楼-- · 2019-01-16 00:18

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
查看更多
叛逆
3楼-- · 2019-01-16 00:18

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

查看更多
爷的心禁止访问
4楼-- · 2019-01-16 00:19

Open the application by name:

open -a 'Atom' FILENAME
查看更多
小情绪 Triste *
5楼-- · 2019-01-16 00:20

With the Atom editor open, in the menu bar:

Click Atom >> Install Shell Commands

atom-add-shell-commands

You should expect to see:

atom-commands-installed

Potentially restart your terminal. (I did just out of habit, not sure if you need to)

查看更多
放我归山
6楼-- · 2019-01-16 00:21

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. apmis the command line package manager.

查看更多
姐就是有狂的资本
7楼-- · 2019-01-16 00:24

I am on mingw bash, so I have created ~.profile file with following: alias atom='~/AppData/Local/atom/bin/atom'

查看更多
登录 后发表回答