Reputation: 2901
I installed a new code editor. Sublime 3. I want to be able to open Sublime from the command terminal so I can use commands like
Editor .
To open a code project whose directory I am in.
To do this I tried linking the Sublime App to my 'usr/local/bin' in the following ways.
ln -s /Applications/Sublime Text.app /usr/local/bin
ln -s /Applications/Sublime Text /usr/local/bin
'Sublime' now shows up in the '/usr/local/bin' directory, however the following commands don't work.
cd /path/code_folder
Sublime .
Sublime Text.app .
Sublime Text .
They all return
-bash: Sublime: command not found
Upvotes: 8
Views: 13153
Reputation: 189417
You linked to the wrong thing. Sublime Text.app
is really a directory, you want to symlink to the actual binary:
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/
This is almost a verbatim copy/paste from the documentation. I kept the name subl
though you could obviously easily use a different name.
Notice also the correct use of quotes; you created a symlink Text.app
and another called Sublime
, neither of which currently points to a valid location. See also When to wrap quotes around a shell variable?
Upvotes: 10
Reputation: 11
Download Sublime Text for Mac.
In your Downloads directory, double-click on Sublime Text.dmg to open it.
Drag Submlime Text 2.app into your Applications folder.
Run below command in your terminal.
ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
Now open file in current directory using subl filename.
Upvotes: 1