可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
Having loads of difficulty getting this set up. I've fixed up my .bash_profile
, created the symlink using the following command from the sublime website:
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
Yet when I input that command I get:
ln: /Users/my_username/bin/subl: No such file or directory
It appears my terminal is looking at the wrong place for the file? Why is it trying to point to a bin
folder on my home directory?
回答1:
create the symlink in /usr/local/bin
instead of ~/bin
and make sure that /usr/local/bin
in in PATH
.
$ ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/.
$ echo $PATH
If you don't find /usr/local/bin/
, then add the following lines to your .bashrc or .zshrc
PATH=$PATH:/usr/local/bin/; export PATH
回答2:
This solved my sublime terminal (subl
) command issue after battling for a while on Yosemite here is the source
sudo su
rm /usr/local/bin/subl
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
exit
回答3:
if you are using "Sublime Text 2" try this:
$ ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
or, if you path is in /usr/bin/ instead /usr/local/bin
$ ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/bin/subl
回答4:
Launch Sublime Text from the command line on OSX
Following the directions above are what worked for me. I use Sublime Text 3 and only had to c+p the below into the cli. I did this at the root level $ cd ~
If your using Sublime Text 3 c+p this into the command line:
// Sublime Text 3
$ ln -sv "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
If your using Sublime Text 2 c+p this code below into the command line:
// Sublime Text 2
$ ln -sv "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
Now test it out to see if it works
Open a new file from the command line:
$ subl test.rb // it should open new file test.rb in Sublime Text
Open a project folder
$ subl dir/myProject // opens a new folder inside Sublime
Launch Sublime app:
$ subl // launches Sublime
To open Sublime Help for more detailed options use:
$ subl -h // Sublime help
回答5:
My similar problem was solved simply by omitting the quotes. So if you're working with:
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
I instead did:
ln -s /Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl ~/bin/subl
回答6:
At my end subl
was working fine but git was unable to access it. And was displaying these errors
subl -n -w: subl: command not found
error: There was a problem with the editor 'subl -n -w'.
For Mac OS X in the file ~/.gitconfig under [core] I had to put this code to solve the issue on my end.
editor = /Applications/Sublime\\ Text.app/Contents/SharedSupport/bin/subl -n -w
回答7:
I'm gonna document this because it worked on my machine™ and might fix the problem for people who see "file already exists" when they run the command suggested in sarbbottam's answer. I'm not sure I can fully explain it so I may use the wrong terms here or there.
When I dutifully copy-pasted sarbbottam's command, my terminal reported that the file already existed. I had tried copy-pasting several stack overflow answers to this problem into my terminal, so I had symlinks called "subl" and "sublime" in my /usr/local/bin: I could see the file when I listed all files in that directory with "ls -a". So I tried to open the "subl" in a text editor, and it said that the file didn't exist!
So I deleted the "subl" symlink in /usr/local/bin, ran the command, and it worked. I think I accidentally made one for Sublime Text 2 or something, and just figured I'd be overwriting the last one which was not the case.
回答8:
There might be an issue with having multiple symbolic links to the same target. I removed my link "subl" and my link "sublime" still works.
回答9:
Geez louise, this was irritating to figure out. I tried several combinations of using sudo and also including or excluding leading / and escaping spaces in the package name Sublime\ Text.app
For me, what worked for creating the desired symlink was:
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
I did not have to use sudo or modify $PATH. For reference, I am on Mac OS Mojave 10.14. echo $PATH currently (and without any modification by me) shows the following:
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
You can tell if this worked by typing "which subl" immediately after running the ln command above. If you don't get a line of output showing you where bash found your subl command... then you don't have it. Best of luck!