问题
I am trying to make a command line link for Sublime Text 3.
If I run /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl
Sublime Text opens like normal.
I then run sudo ln "/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl" /usr/bin/subl
Restart the terminal and I get this:
$ ls /usr/bin/subl
/usr/bin/subl
$ subl
-bash: subl: command not found
I also tried setting in my .profile
alias subl="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
but I also get command not found
EDIT:
/usr/bin/
is in my PATH
as well
EDIT2:
I tried a restart of my computer but still doesn't work.
It seems any new alias I make won't work in my .profile
.
I tried ln -s "/usr/bin/mail" /usr/bin/testln
and it did work.
EDIT3:
I got it to work by putting an alias in .bash_profile
instead. I would still like to know why my ln
doesn't work though.
回答1:
Your symlink command
sudo ln "/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl" /usr/bin/subl
didn't work because you both enclosed the path in quotes and escaped the space with a backslash. The quotes make the symlink point to the literal path
/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl
which is not valid. You should use either
"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
or
/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl
but don't combine the two.
回答2:
You can add the alias in your .profile
file as :
alias subl="open -a Sublime\ Text"
After you do that
subl .
Should work just fine
来源:https://stackoverflow.com/questions/18909603/mac-terminal-link-not-working