Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to create the link about sublime text2 which is placed in applications.

If I paste the /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl in bash, the sublime text 2 will open.

And I use the

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

and I check that my path has add the /usr/local/bin by echo $PATH which results in /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:

and I cd to the /usr/local/bin and found there is a subl script but I use vim to open it, the file is all blank.

And I restart the terminal and type subl but results -bash: subl: command not found.

How do I fixed it?

share|improve this question
1  
if you use sublime text 3, the issue is fixed, at least on linux (don't have osx so dont how osx woorks) they started to offer .deb installable packages and not just zip files with an executable file. I can do subl abc.txt from terminal, by default, so you might want to try it –  Fischer Sep 6 '13 at 17:27
    
@Fischer - OSX doesn't support .deb packages, so unfortunately that solution is irrelevant here. Creating the subl link isn't too hard, you just need to make sure the path is correct - see my answer below. –  MattDMo Sep 7 '13 at 19:10

1 Answer 1

up vote 1 down vote accepted

If you don't want to use Sublime Text 3 yet, which has a lot of differences from Sublime Text 2, and is still in beta, here's how to fix your problem. Just run each of these commands (in order) from Terminal and you should be all set:

sudo rm -rf /usr/local/bin/subl

This will remove whatever subl links are in /usr/local/bin. Then:

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

This recreates the link to the proper location. Make sure you run the command exactly as I typed it, or it won't work. I'll explain why in a moment. Finally, restart Terminal and enter:

subl

to make sure the process worked.


The reason your

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

command didn't work was because you included the Applications/... path in quotes " and also escaped the spaces using a backslash \. You should do one or the other, but not both. My command above just uses \ to escape the spaces. When you use quotes, each character in the string is included literally, including the \ characters. This is why the file was blank when you opened it in vim - it was pointing to a path that didn't exist.

By the way, while you can open /usr/local/bin/subl in vim, I wouldn't recommend it because it's a binary executable file, so you'll just get garbage on your screen.

Good luck!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.