Juicy lil' bytes

How to Open a File in Sublime Text 2 or 3 From the Command Line on Mac OSX

You can open a file in Sublime Text from the Mac command line. Here is how you do it with versions 2 and 3 of this popular text editor.

Sublime Text 2

Create a symbolic link to the subl binary with this command:

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

Sublime Text 3

The install path is different in Sublime Text 3. Create the symbolic link like this:

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

Confirm that it Works

Confirm that it works by accessing the help file with the --help switch:

subl --help

If you receive an error, make sure that /usr/local/bin is on your PATH.

Use it on the Command Line

Use the filename as the argument to subl. If there are spaces in the filename path, make sure that you surround the entire path with double quotes or escape the spaces.

Here is an example with the file ‘test.txt’:

subl test.txt


Here are links to the Sublime Text 2 and Sublime Text 3 command line use documentation if you’d like to learn more.