bash Sublime Text 2 - OS X 命令行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13655343/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 03:54:18  来源:igfitidea点击:

Sublime Text 2 - OS X Command Line

bashterminalsublimetext2

提问by Pavel Binar

Original Sublime 2 instructionfor enabling editor to launch from command line:

使编辑器能够从命令行启动的原始 Sublime 2指令

ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl

do not work in Mountain Lion.

不要在 Mountain Lion 中工作。

回答by zneak

Create the ~/bindirectory if it doesn't already exist:

~/bin如果目录不存在,则创建该目录:

mkdir ~/bin

Then run the lnagain. Make sure that directory is added to your $PATHby adding this to the ~/.bashrc file, creating it if it doesn't exist:

然后ln再次运行。$PATH通过将其添加到 ~/.bashrc 文件来确保将目录添加到您的目录中,如果它不存在则创建它:

export PATH="$PATH:~/bin"

If you don't use bash, use your manual to figure out how to add a directory to your $PATHvariable.

如果您不使用 bash,请使用您的手册​​找出如何将目录添加到您的$PATH变量中。

This is actually what the instructions say:

这实际上是指令所说的:

The first task is to make a symlink to subl. Assuming you've placed Sublime Text 2 in the Applications folder, and that you have a ~/bin directory in your path, you can run: [snip]

第一个任务是创建一个到 subl 的符号链接。假设你已经把 Sublime Text 2 放在 Applications 文件夹中,并且你的路径中有一个 ~/bin 目录,你可以运行:[snip]

This implies you need to create the ~/bindirectory if it doesn't exist, and add it to your $PATHif it is not there already. The above instructions do exactly that.

这意味着~/bin如果目录不存在,您需要创建该目录,如果它已经不存在,则将其添加到您的目录中$PATH。上面的说明正是这样做的。

If you don't like that ugly binfolder in your pretty home folder, you can use chflagsto make it disappear from the Finder:

如果您不喜欢bin漂亮的主文件夹中那个丑陋的文件夹,您可以使用chflags使其从 Finder 中消失:

chflags hidden ~/bin

回答by Pavel Binar

Change target directory to system folder /usr/bin and use sudo for admin rights.

将目标目录更改为系统文件夹 /usr/bin 并使用 sudo 获得管理员权限。

sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /bin/subl

回答by Maalur

I recently ran into this problem on OSX Mountain Lion and then again on Mavericks. This solution worked for me:

我最近在 OSX Mountain Lion 上遇到了这个问题,然后又在 Mavericks 上遇到了这个问题。这个解决方案对我有用:

Create the bin directory in /usr/local/bin if it doesn't already exist:

如果 bin 目录不存在,则在 /usr/local/bin 中创建它:

sudo mkdir /usr/local/bin

You have to use sudo and enter your password to create the directory because it is inside a system folder.

您必须使用 sudo 并输入密码才能创建目录,因为它位于系统文件夹中。

Setup sublas a command-line command in the /usr/local/bin:

subl在 /usr/local/bin 中设置为命令行命令:

sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl

The directory /usr/local/bin is already in your $PATHby default, even if it doesn't exist yet, so there is no need to add it to your $PATH. The folder /usr/local is also the folder used for git and homebrew installs, so it makes sense to keep all your local command-line commands in this location.

$PATH默认情况下,目录 /usr/local/bin 已经在您的目录中,即使它还不存在,因此无需将其添加到您的$PATH. 文件夹 /usr/local 也是用于 git 和 homebrew 安装的文件夹,因此将所有本地命令行命令保留在此位置是有意义的。

回答by Vincent van Leeuwen

Maybe its already here, but this one worked like a charm for me:

也许它已经在这里了,但这个对我来说就像一种魅力:

ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl