简体   繁体   中英

Sublime Text 2 - OS X Command Line

Original Sublime 2 instruction for enabling editor to launch from command line:

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

do not work in Mountain Lion.

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

mkdir ~/bin

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

export PATH="$PATH:~/bin"

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

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]

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

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

chflags hidden ~/bin

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

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

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

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

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.

Setup subl as a command-line command in the /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 $PATH by 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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM