Sublime Text includes a command line tool, subl
, to work with files on the command line. This can be used to open files and projects in Sublime Text, as well working as an EDITOR for unix tools, such as git and subversion.
- Sublime text 2 or 3 installed in your system within
Applications
folder
In order to launch sublime from command line you only need to create a symlink /usr/local/bin/subl
point to sublime app, to do so run the following in the command line.
ln -sv "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
ln -sv "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
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/project
to launch Sublime app
subl
for more detailed options use the help:
subl -h
run the command as follows:
git config --global core.editor "subl -w"
to config git to use Sublime Text as editor only for a particular repository/project run the same command above without --global
option.
have created a directory where you actually place binaries /usr/local/bin
if not make it before creating a symlink
:
mkdir -p /usr/local/bin
have /usr/local/bin
in your PATH environment variable, if not add by running the following command:
echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bash_profile
then reload the shell:
source ~/.bash_profile
test again.
Further info read from sublime docs
Sorry @janeygak I haven't tested on El Capitan OS, I'm just about to migrate from Mavericks to El Capitan OS, after I test it out I updated here.
UPDATE:
@janeygak it's a bit late but, I've test it out on El Capitan, and yet it works flawlessly for both ST2 and ST3 ;).
So if you still have a trouble, I guess you may check on of the following steps:
1: Check if the
subl
command does exists is in your PATH, type in terminal the following command:You should see something like:
/usr/local/bin/subl
, if the output is empty you probably haven't to created symlink.2: Make sure the bin folder from the result above is in your PATH:
You should see in the output:
/usr/local/bin
, if not, follow the note described at bottom of the gist.bin
folder and the symlink point to thesubl
properly.Should see in the output:
subl -> /Applications/Sublime Text.app/Contents/SharedSupport/bin/subl
If none of these works let me know.