9

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.

4 Answers 4

21

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
4
  • This worked perfectly for me, but every time I close and reopen my terminal, I am forced to re-input export PATH="$PATH:~/bin", any idea how to make this stick? Thanks! Sep 26, 2013 at 21:08
  • Yes. It seems you missed step 2 about the .bashrc file.
    – zneak
    Sep 26, 2013 at 23:35
  • my bin folder is within Users/myname/bin. It contains subl. How can I make it so that this is used? Oct 9, 2013 at 17:46
  • 2
    ~ means "your home folder", so ~/.bashrc means "the file called .bashrc inside /Users/myname". Create that file, and put the export PATH="$PATH:~/bin" line in it. The changes will apply to every subsequent terminal window.
    – zneak
    Oct 9, 2013 at 18:14
11

Change target directory to system folder /usr/bin and use sudo for admin rights.

sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /bin/subl
3
  • 3
    This works only because in OSX /bin is already on $PATH and ~/bin by default is not.
    – om-nom-nom
    Dec 1, 2012 at 1:14
  • Don't add stuff to /bin. /bin should be reserved for built-in executables. /usr/bin is the right place for non-system executables available for all users (and ~/bin is the right place for non-system executables available for just you).
    – zneak
    Dec 1, 2012 at 1:16
  • 1
    OK, thanks! I found an solution that works, but was not right conceptually. Good to know. Dec 1, 2012 at 22:55
4

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.

0

Maybe its already here, but this one worked like a charm for me:

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

Your Answer

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

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