I’m using Mac OS X Yosemite and I want to be able to open Sublime Text 2 from the terminal with a command like this:
sublime .
I’ve typed this into terminal as shown on the Sublime Text 2 website:
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/sublime
And also this variant:
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime
In the terminal, if I type in:
echo $PATH
I get:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
I’ve tried editing my .bash_profile
, right now it’s blank
After all this, I try sublime .
and get the following error:
-bash: sublime: command not found
I’m completely new to Mac OS X, and terminal configuration, and am really struggling to figure out why I can't get it to work so any help would be appreciated.
Best Answer
Try running the back-slashed/escaped version of the
ln -s
command as explained here like so:As that site explains—and I concur—the
~/bin
that the official Sublime Text site recommends just seems weird and I have never encountered a recommendation like that for local binaries before. So avoid using it.But what is also weird in all examples is that
sudo
is not being used. That/usr/local/bin
directory is a root system directory and is not normally writable by anyone butroot
. So with that in mind just run the above command viasudo
like this:Of course you will now have to enter your root/administrator password. But once that is done the symbolic link should be in place. And to confirm it’s there just run this command from the terminal:
The output should be a directory listing with dates/times that looks something like the following: