Sublime Text 2 command line not working after Mave

2019-02-19 23:12发布

问题:

I've ready through other threads on Stack Overflow and despite my efforts the issue doesn't seem to resolve. Since installing OS X Mavericks I'm not able to open Sublime Text 2 from the command line.

I've tried following these guidelines:

http://benkwok.wordpress.com/2013/11/17/setup-sublime-text-2-on-osx-mavericks-for-ruby-on-rails/

When I run this from the terminal Sublime pops up so that's good: http://benkwok.wordpress.com/2013/11/17/setup-sublime-text-2-on-osx-mavericks-for-ruby-on-rails/

I've added these lines to the bottom of my bash_profile:

export PATH=/bin:/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$PATH↲
export EDITOR='subl -w'

However, when I try to run:

source ~/.bash_profile

from the command line I get:

-bash: rbenv: command not found
-bash: rbenv: command not found
-bash: Gemfile: command not found

When I try to subl . from inside a folder with files in it, I get the following error:

-bash: subl: command not found

So, my bash_profile is obviously configured wrong for Mavericks. Any and all help appreciated.

回答1:

There are a couple of things wrong with that blog post. First, the symlink is pointing to the wrong target if you're using Sublime Text 2. It should be

sudo ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

as the application's name is Sublime Text 2.app. Sublime 3 is named Sublime Text.app. Make sure you run

sudo rm /usr/local/bin/subl

to delete the old (incorrect) symlink before making the new one.

Next, there is an invalid character in the export PATH command. It should be

export PATH=/bin:/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$PATH

without the character at the end.

Make these changes, exit Terminal and restart, and you should be able to run subl . to open a folder, or subl filename to open individual files.