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

后端 未结 18 1836
天命终不由人
天命终不由人 2020-12-02 03:44

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:

at         


        
相关标签:
18条回答
  • 2020-12-02 04:06

    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.

    0 讨论(0)
  • 2020-12-02 04:06

    On macOS you can add it to your ~/.bash_profile

    as

    alias atom='open -a "Atom"'

    and from terminal just call

    atom filename.whatever

    0 讨论(0)
  • 2020-12-02 04:06

    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.

    1. Move "Atom X" from Documents into Applications (why it ended up in here, I have no idea)
    2. Rename "Atom X" to "Atom"
    3. Might need to restart your terminal and Atom

    After that everything should work just like it did before. Hopefully this saves someone 30 minutes of poking around.

    0 讨论(0)
  • 2020-12-02 04:06

    Make sure to put (move) the atom into Application directory.

    0 讨论(0)
  • 2020-12-02 04:09

    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)

    0 讨论(0)
  • 2020-12-02 04:09

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

    0 讨论(0)
提交回复
热议问题