Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2  is a sophisticated text editor for code, markup and prose. You’ll love the slick user interface, extraordinary features and amazing performance.

Launching Sublime Text 2 from the Terminal is possible as it ships with a CLI called subl. The first task is to make a symlink to subl. Assuming you’ve placed Sublime Text 2 in the Applications folder, you can run:

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

Now let’s do a check to see if everything will run smoothly. Enter this:

open ~/.bash_profile

This contains all the directories that will be looked into for executable binaries when you type a command in Terminal. Since we create a symlink to subl called sublime in the /usr/local/bin directory, make sure it’s added to your path. If it is, perfect. Let’s keep going. If not, simply add it:

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

If you had to add /usr/local/bin to your PATH, run the following command before continuing:

source ~/.bash_profile

This will reload your .bash_profile with the newly added directory. Now everything is ready, so run:

sublime filename

or

sublime foldername

or even

sublime .

to open the entire current directory.

Have fun, Sublime is a great editor showing a lot of promise.

Advertisements