如何在OS X中从命令行打开Atom编辑器?

本文翻译自: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. 我有Atom编辑器,想知道如何在Atom中从终端打开文件或文件夹。 I am using a Mac. 我正在使用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? 这是可能的,我该如何设置?


#1楼

参考:https://stackoom.com/question/1VwqT/如何在OS-X中从命令行打开Atom编辑器


#2楼

When Atom installs it automatically creates a symlink in your /usr/local/bin. 当Atom安装时,它会自动在/ usr / local / bin中创建一个符号链接。 However in case it hasn't, you can create it yourself on your Mac 但是,如果没有,您可以在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. 现在,您可以使用atom folder_name打开文件夹和atom file_name来打开文件。 Hope this helps. 希望这可以帮助。


#3楼

Roll your own with @Clockworks solution, or in Atom, choose the menu option Atom > Install Shell Commands. 使用@Clockworks解决方案自行滚动,或在Atom中,选择菜单选项Atom> Install Shell Commands。 This creates two symlinks in /usr/local/bin 这会在/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. 使用atom命令可以完全按照您的要求进行操作。 apm is the command line package manager. apm是命令行包管理器。


#4楼

With the Atom editor open, in the menu bar: 打开Atom编辑器,在菜单栏中:

Click Atom >> Install Shell Commands 单击Atom >>安装Shell命令

原子的添加壳命令

You should expect to see: 你应该期望看到:

原子的命令装

Potentially restart your terminal. 可能重启你的终端。 (I did just out of habit, not sure if you need to) (我只是出于习惯,不确定是否需要)


#5楼

按名称打开应用程序:

open -a 'Atom' FILENAME

#6楼

I had problems due to atom being unable to write its logfile when starting from the commandline. 我遇到问题,因为当从命令行启动时,atom无法写入其日志文件。 This cured it. 这治好了。

sudo chmod 777 ~/.atom/nohup.out sudo chmod 777~ / .atom / nohup.out


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部