[英]How do I link an application to usr/local/bin so I can call it globally in the terminal. Mac
I installed a new code editor. 我安装了一个新的代码编辑器。 Sublime 3. I want to be able to open Sublime from the command terminal so I can use commands like
Sublime3。我希望能够从命令终端打开Sublime,所以我可以使用类似的命令
Editor .
To open a code project whose directory I am in. 打开我所在目录的代码项目。
To do this I tried linking the Sublime App to my 'usr/local/bin' in the following ways. 为此,我尝试通过以下方式将Sublime应用链接到我的'usr / local / bin'。
ln -s /Applications/Sublime Text.app /usr/local/bin
ln -s /Applications/Sublime Text /usr/local/bin
'Sublime' now shows up in the '/usr/local/bin' directory, however the following commands don't work. “ Sublime”现在显示在“ / usr / local / bin”目录中,但是以下命令不起作用。
cd /path/code_folder
Sublime .
Sublime Text.app .
Sublime Text .
They all return 他们都回来了
-bash: Sublime: command not found
You linked to the wrong thing. 您链接到错误的内容。
Sublime Text.app
is really a directory, you want to symlink to the actual binary: Sublime Text.app
是一个目录,您想要符号链接到实际的二进制文件:
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/
This is almost a verbatim copy/paste from the documentation . 这几乎是文档中的逐字复制/粘贴。 I kept the name
subl
though you could obviously easily use a different name. 尽管您显然可以轻松使用其他名称,但我保留了
subl
名称。
Notice also the correct use of quotes; 还请注意正确使用引号; you created a symlink
Text.app
and another called Sublime
, neither of which currently points to a valid location. 您创建了一个symlink
Text.app
和另一个名为Sublime
,它们当前均未指向有效位置。 See also When to wrap quotes around a shell variable? 另请参见何时在引号周围包裹引号?
Download Sublime Text for Mac. 下载Mac版Sublime Text。
In your Downloads directory, double-click on Sublime Text.dmg to open it. 在您的下载目录中,双击Sublime Text.dmg将其打开。
Drag Submlime Text 2.app into your Applications folder. 将Submlime Text 2.app拖到“应用程序”文件夹中。
Run below command in your terminal. 在终端中运行以下命令。
ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
Now open file in current directory using subl filename. 现在,使用subl文件名在当前目录中打开文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.