40
votes

I've downloaded and installed Sublime text 2. I am following the directions here: but I am stuck at this part:

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:

ln -s "/Applications/Sublime Text " ~/bin/subl

However, when I do this it tells me /Users/User/bin/subl: No such file or directory.

What should I do?

Thanks!

8
Here are another instructions for this matter: opensourcehacker.com/2012/05/11/… - Mikko Ohtamaa

8 Answers

51
votes

I'd recommend adding it to your local bin:

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

Edit: Make sure your local bin directory exists before running this command:

mkdir /usr/local/bin
24
votes

I add my sym links to /usr/local/bin, for Sublime Text 3 I set mine up like so:

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

Then you can open up the current directory list using:

subl .

If you find subl abbreviation annoying as some people I know seem to do, then change it to 'sublime'

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

And call it using:

sublime .
14
votes

Alternatively, you can run this:

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

Note: The above snippet puts the symlink in /bin/subl rather than ~/bin/subl.

7
votes

and that you have a ~/bin directory in your path

First, you need that directory for the ln command to work, and eventually, it will need to be in your path to do whatever it is you are trying to do.

To make the directory:

mkdir ~/bin

Adding it to your execution path is trickier, but there are plenty of resources available.

3
votes

Following Simon's example above, For Sublime Text 3, here is what worked for me:

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

Please note, to install (on Mac OS Sierra 10.12.6) in /usr/local/bin sudo was required.

2
votes

Info

  • OS: Mac OSX High Sierra 10.13.6 (17G65)
  • Sublime Version: Version 3.1.1 Build 3176

I took the command from SublimeText website

Got An Error

ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl
ln: /Users/jkirchoff/bin/subl: No such file or directory

Did Some Checking

Just to make sure the path exists.

NOTE: the "'s allow the space in the path.

ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
ln: ./subl: File exists

Compared Note from this page

What @NotSimon wrote on this page, Then Ran:

ln -s "/usr/local/bin/subl"
ln: ./subl: File exists

and then followed the rest.

The Complete Line that worked for me:

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

Success

Now I can run subl as a command in Terminal!

This command opens the directory as a "Project" in SublimeText.

subl ~/Desktop

Optional

I followed the SublimeText recommendation & added this to my ~/.bash_profile.

The command works without it, just following guidelines.

echo "export EDITOR='subl -w'" >> ~/.bash_profile

1
votes

Just remove tilde ~ from ~/bin/subl

0
votes

If you're using mac terminal, just replace "Sublime Text 2.app" with "Sublime\ Text\ 2.app/" anywhere within the command.

That should do it.