I have installed Sublime on my Mac Lion Laptop, and followed the guide here http://www.sublimetext.com/docs/2/osx_command_line.html but as always it did not work. I dont have a ~/bin directory on my Mac. Any help?


You could create the symlink in /usr/bin:

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

If you don't have a ~/bin directory, you can create one with mdkir ~/bin. This should allow you to follow the guide.

If you do this and Sublime is still not working for you after you've set everything up, then this new folder is probably not included in your $PATH (a list of folders that command-line shells search for executables). You can check if this is the case by running echo $PATH and see if it contains /Users/<your username>/bin. If you don't see the new folder we created in your $PATH, then you'll have to add it: Add folder to PATH

A more appropriate location to link the subl exceutable might be /usr/local/bin if it exists.

  1. Create a bin directory in your home folder using the Finder or by typing mkdir ~/bin in the terminal.

  2. Create a symlink to the subl app in that bin folder by typing sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl in the terminal.

  3. Open or create a file called .bash_profile (note the dot!) in your home directory using Sublime Text. (Your home directory will be the one in the Finder with the home icon. You can get the Finder to show the home directory quickly by typing open ~ in the terminal.)

  4. Add the ~/bin directory to your $PATH by editing the .bash_profile file you've just created and adding the line export PATH=$PATH:~/bin. Then save the file.

  5. Reload your .bash_profile so that the updated $PATH is picked up by typing source ~/.bash_profile in the terminal.

You should now be able to use the subl command at the terminal prompt. It's also worth noting that you can put the bin folder anywhere you like if you don't want to put it in your home folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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