Sublime Text 3 and Terminal prompt for OS X Mavericks?
Solution 1
Should be:
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime
Notice I removed the tilde (~
). Tilde (~
) in Unix refers to your user's home directory, so your source was correct, but the second argument was placing the link in /Users/[your username]/usr/local/bin/ which is not included in $PATH.
In your note, you said you tried removing the quotes from the source argument. If you remove the quotes, you need to be sure to escape the space character as follows:
ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime
That should work as well.
Solution 2
Mavericks does not ship with a ~/bin directory, but found I ran into trouble trying to install the subl
command in any of the low-level system bin directories. I found the following solution worked neatly:
Create a ~/bin directory for your user:
mkdir ~/bin
Add the subl
command as per the Sublime Text documentation:
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl
Open /etc/paths in your (second) favourite text editor:
sudo vi /etc/paths
Add the active user's ~/bin folder. Here's how mine looked after I'd added ~/bin:
~/bin
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
Solution 3
Rather than having cumbersome sudo links to setup I prefer to use a simple bash function and use the native Mac open
command:
#somewhere in your .bashrc or .zshrc
sublime () {
open -a "Sublime Text" $@
}
Now all you have to do is sublime .
whenever you want to open up sublime from a given folder. Obviously you can simply rename it subl
.
Note
The name to write in the -a
parameter is the name of the application as stored in the the /Applications
folder:
Solution 4
After a few days of struggling with the issue, this worked for me.
Make sure you have ~/usr/bin
set in $PATH
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/bin/subl
If you get a permission denied error:
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/bin/subl
Type in your password.
Solution 5
This works for me as well:
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/st
Than you can write just:
st filename.file extension
It should works. I tried so many things but this worked first.
Zoop
Updated on July 09, 2022Comments
-
Zoop almost 2 years
I'm trying to set-up Sublime Text 3 on OS X Mavericks and getting levels of frustration.
I've followed all of the usual suspects in regards to installation and setup, i.e. Googling the Sublime Text website, and Stack Overflow. Inevitably it's something minor I'm missing, but it's causing me major heartburn.
What I've done so far:
- Downloaded Sublime Text 3, sitting in my /Applications directory
- Followed the guide Launch Sublime Text 2 from Mac Terminal
The problems starts here. I know that the symlink presented in this link is using ST2, but I want to use "
sublime
" instead of the "subl
"(personal preference). I searched around and found what I need to paste into Terminal for ST3:ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/usr/local/bin/sublime
-
Already had a ~/.bash_profile:
export PATH=/usr/local/bin:$PATH
. However, when Iecho $PATH
I get:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin
Does this look correct?
- Now when I type
sublime
into the terminal I getcommand not found
What am I missing. This is driving me crazy as I fell that I have followed all the steps, but ST3 is still not working for me
-
Zoop over 10 yearsI copy/pasted your first bit of code into terminal. Terminal returns
ln: /usr/local/bin/sublime: File exists'. When i type in
sublime` into terminal I still getcommand not found
. This is the source of my confusion/frustration. -
Admin over 10 years@Zoop, you most likely created
/usr/local/bin/sublime
when you ran theln
command without the ~. Tryls -l /usr/local/bin/sublime
and you'll see something like:/usr/local/bin/subl -> /Applications/Sublime
. If so,rm /usr/local/bin/sublime
and then run theln
command I provided again. -
Zoop over 10 yearsFIXED. Thanks man, I was pulling my hair out. I'm not sure what I did that screwed things up, but everything is fixed. I run sublime in terminal and ST3 window pops up ready to go to work. Thanks for the help - have a good one!
-
Frans over 10 years/usr/bin is not the same as ~/usr/bin. The permission denied error would occur if you use /usr/bin.
-
Bebop_ over 10 yearsI know they're not the same. I'm just saying that solution worked for me.
-
Sinan Eldem almost 10 yearsPrefered this method and it worked for me. Using /usr/local/bin folder seems to be the best idea.
-
Lukas about 9 yearsTo everyone being slightly confused why they get the error
command not found: subl
, the author (and the op) ask for linkingsublime
rather thansubl
(the latter is common and used on sublime's homepage) -
Narek over 8 yearsNice, thanks. How to open not a new sublime but in new sublime tab if a sublime instance is open already.