简体   繁体   English

如何将应用程序链接到usr / local / bin,以便可以在终端中全局调用它。 苹果电脑

[英]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.

相关问题 如何告诉 bash 使用 /usr/local/bin/python3 而不是 /usr/bin/python3? - How do I tell bash to use /usr/local/bin/python3 instead of /usr/bin/python3? 自制链接python到/ usr / local / bin /在Mac上 - Homebrew link python to /usr/local/bin/ on Mac Output 在 linux 终端中丢失。 我该如何恢复? - Output was lost in linux terminal. How do I restore? 每当我打开终端时,我都会得到 'bash: export: `/home/shameen:/usr/bin:/usr/local/bin': not a valid identifier' - Whenever I open terminal I get 'bash: export: `/home/shameen:/usr/bin:/usr/local/bin': not a valid identifier' 钩在终端上。 我可以在终端中运行命令之前调用方法吗? - Hooks on terminal. Can I call a method before a command is run in the terminal? Linux:安装后在我的/ bin /或/ usr / bin中找不到期望。 我如何找到它? - Linux: Can't find expect in my /bin/ or /usr/bin after installing. How do I find it? .bashrc 命令正在回显到终端。 我能阻止这个吗 - .bashrc commands are echoing to terminal. Can I stop this 在Mac OSX上如何将脚本文件与终端关联,以便双击图标启动终端? - On Mac OSX how can I associate a script file with Terminal so double clicking the icon launches Terminal? 哪个ctags显示/ usr / local / bin / ctags但是当我运行ctags时它会运行/ usr / bin / ctags。 这怎么可能? - which ctags shows /usr/local/bin/ctags but when I run ctags it runs /usr/bin/ctags. How is this possible? mvn -version显示-bash:/ usr / local / bin / mvn:没有这样的文件或目录。 知道我该如何解决吗? - mvn -version is displaying -bash: /usr/local/bin/mvn: No such file or directory. Any idea how I can fix this?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM