41

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!

user1404456
  • 559
  • 2
  • 5
  • 5
  • 2
    Here are another instructions for this matter: http://opensourcehacker.com/2012/05/11/sublime-text-2-tips-for-python-and-web-developers/ – Mikko Ohtamaa May 21 '12 at 23:51

8 Answers8

53

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
NotSimon
  • 1,795
  • 1
  • 21
  • 31
  • 2
    I've got "ln: /usr/local/bin/subl: No such file or directory" – onmyway133 Jul 08 '14 at 15:54
  • 1
    @onmyway133 does your bin directory exist? – NotSimon Jul 09 '14 at 16:23
  • 1
    This worked for me but had to run as `sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl` – Shanerk Feb 08 '18 at 00:25
  • Thanks, this worked for me. I don't fully understand why yet, but I found [this](https://unix.stackexchange.com/a/4194/302720) useful in explaining some context – stevec Aug 07 '20 at 13:47
24

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 .
Kingsley Ijomah
  • 3,273
  • 33
  • 25
14

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.

Trent Scott
  • 2,018
  • 8
  • 34
  • 50
  • 2
    what's the difference between adding a tilde? (~) – ayjay Apr 23 '14 at 13:59
  • @ayjay the tilde references your home directory. So /bin/subl starts at the root of your system, while ~/bin/subl starts at your home directory - it's a shortcut for the directory (on a Mac) /Users/ – NotSimon Jul 09 '14 at 16:25
7

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.

jgritty
  • 11,660
  • 3
  • 38
  • 60
3

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.

Shanerk
  • 5,175
  • 2
  • 40
  • 36
2

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

JayRizzo
  • 3,234
  • 3
  • 33
  • 49
1

Just remove tilde ~ from ~/bin/subl

Inder Kumar Rathore
  • 39,458
  • 17
  • 135
  • 184
dEtRoiX
  • 26
  • 1
0

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.

Matt C.
  • 2,330
  • 3
  • 22
  • 26