pkro8g
Last Updated: October 28, 2018
·
4.777K
· 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

1458

Install oh-my-zsh and enable sublime plugin.

over 1 year ago ·
1482

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

over 1 year ago ·
1826

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

over 1 year ago ·
4896

Thank you ^^

over 1 year ago ·
5566

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 ·
8358

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 ·