53

I'm tryng to use Sublime Text from the terminal, for example by typing subl.

I'm following the steps from Sublime Text's website:

Setup

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 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl

I keep getting permission denied : ~/bin/subl: Permission Denied

I have been searching around for a similar problem but can't find one that's applicable. Can someone point me to the right direction?

3
  • I'm on the admin account of my OS X Lion laptop Commented Apr 17, 2012 at 17:59
  • 1
    got it used: sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl Commented Apr 17, 2012 at 21:24
  • I've done this but the subl command doesnt work for me... Just get command not found. Any ideas? Commented May 4, 2012 at 21:26

3 Answers 3

102

I am assuming that you don't have the bin directory. You can do the following:

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

ln -s will create a alias of the subl file in your bin directory and you will be able to run the command.

If this still doesn't work you will have to edit your .bash_profile. You can do it by following commands: (NOTE: For this to work you need to have done the above steps already.)

  1. Open your .bash_profile:

    cd                  // this will get you back to home directory
    vim .bash_profile   // this will open your .bash_profile file
    
  2. Edit .bash_profile: press I to get into "insert" mode and add following:

    export PATH=$PATH:~/bin
    
  3. Save and exit. Press Esc to get into command mode:

    :wq   // saves and close file
    exit  // exits terminal
    
  4. Reopen the terminal:

    subl --help
    

That should bring up the help for Sublime Text.

4
  • 1
    I kept trying editing bash_profile before this post but didn't restart terminal. Didn't work... Now done! YAY!
    – Jono
    Commented Nov 19, 2013 at 2:04
  • 1
    Why would you create a bin directory in your home folder and then create a symbolic link to /usr/bin/subl?
    – Martijn
    Commented Feb 20, 2014 at 13:23
  • You'd think someone would make a "brew install subl" command... no... Error: No available formula for subl Commented Aug 13, 2014 at 0:34
  • 1
    @MartinCleaver You should check brew cask. github.com/caskroom/homebrew-cask Once installed you can do something like brew cask install sublime-text
    – Subash
    Commented Jan 14, 2015 at 3:27
45

My personal preference for the path to the third-party application-specific symbolic links (e.g. subl, brew, github, mate, etc) is:

/usr/local/bin

Why not /usr/bin/?

  1. /usr/bin is a "sacred" place. It is generally recommended to store static binaries that are maintained by package management systems. subl is not this case.

  2. subl is not stable enough to be stored in /usr/bin with other basic BSD binaries (e.g. find, man, make, etc). You must modify/delete subl symbolic link manually if (a) the developers of Sublime Text Editor decide to change its app name in the future releases (as BBEdit Lite was changed to TextWrangler after version 6.1), or (b) you may simply wish to uninstall Sublime Text Editor.


Therefore, I suggest you execute the following line, assuming /usr/local/bin/ exists:

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

Check whether "~/bin/" is included in the path.

A better options is to create the symlink in /usr/bin directory instead.

sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/bin/subl
1
  • 1
    type "echo $PATH" to see the path. Look for /usr/bin:/bin: If its there then the above command should work fine, It did for me. Thanks user1427458 Commented Jul 4, 2012 at 13:11

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.