Instantly share code, notes, and snippets.

What would you like to do?
Launch Sublime Text from the command line on OSX

Launch Sublime Text from the command line on OSX

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.

Sublime Text 2

ln -sv "/Applications/Sublime Text" /usr/local/bin/subl

Sublime Text 3

ln -sv "/Applications/Sublime" /usr/local/bin/subl

Test it out

type in command line

subl test.rb

it should open new file test.rb sublime text

NOTE: To accomplish this you must:

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


This comment has been minimized.

mykeverest commented Dec 1, 2016

I have done all these but the code returns: -bash: subl: command not found. pls help


This comment has been minimized.

jeqq commented Jan 31, 2018



This comment has been minimized.

skxo commented Apr 14, 2018



This comment has been minimized.

johnbarsoum commented May 4, 2018

This was super helpful!! Thanks for this!


This comment has been minimized.

calchulus commented Jun 4, 2018

I get the following despite having gone through all of this
MacBook-Pro-6:/ calvinchu$ ln -sv "/Applications/Sublime" /usr/local/bin/subl
ln: /usr/local/bin/subl: File exists
MacBook-Pro-6:/ calvinchu$ subl test.rb
-bash: subl: command not found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment