Last Updated: August 12, 2019
·
5.135K
· calamari

Open Sublime Text 2 from the console (MacOS X)

Sublime Text 2 is an awesome text editor, which gains a bigger userbase every hour. And I think it is more popular than Textmate nowadays.

One hidden feature of Sublime is, that it comes with a command line program. It's called subl (I guess it should have the same length then the famous mate) and you will find it in the SharedSupport/bin directory of the app itself. There:

/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

The only thing you have to do, is add it to the PATH variable, and reload the terminal. I like to just add it in the ~/.bash_profile, where I just add the line:

export PATH=/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/:$PATH

And after reloading that file (or simple opening a new terminal):

source ~/.bash_profile

you can do simple things like:

$ subl .

or

$ subl ~/my_project

Have fun with that.

6 Responses
Add your response

Install oh-my-zsh and enable sublime plugin.

over 1 year ago ·

it's similar to the mate command that TextMate comes with, I use both quite a lot

over 1 year ago ·

I went extreme by running subl in a headless dev guest machine and then forwarded through X11.

over 1 year ago ·

Thank you ^^

over 1 year ago ·

Say I wanted to have this be available without having to run source ~/.bash_profile every time I open a new terminal instance (as I currently do), whereabouts would I start with that?

over 1 year ago ·

Of course, you could also symlink it into the /usr/local/bin directory, so you would not need to put anything into the .bash_profile

over 1 year ago ·