42

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!

1

8 Answers 8

54

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
4
  • 2
    I've got "ln: /usr/local/bin/subl: No such file or directory"
    – onmyway133
    Jul 8, 2014 at 15:54
  • 1
    @onmyway133 does your bin directory exist?
    – NotSimon
    Jul 9, 2014 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 8, 2018 at 0:25
  • Thanks, this worked for me. I don't fully understand why yet, but I found this useful in explaining some context
    – stevec
    Aug 7, 2020 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 .
2
  • I followed this entire procedure, but subl . results in: -bash: subl: command not found Sep 29, 2018 at 16:01
  • 1
    ln: /usr/local/bin/: No such file or directory
    – user5306470
    May 9, 2019 at 16:05
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.

2
  • 2
    what's the difference between adding a tilde? (~)
    – ayjay
    Apr 23, 2014 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/<yourusername>
    – NotSimon
    Jul 9, 2014 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.

1
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.

1
  • 1
    This is confirmed working with ST3 and OS X 10.15.3 - with sudo and /usr/local/bin/subl Feb 28, 2020 at 18:28
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

1

Just remove tilde ~ from ~/bin/subl

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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