Quick Tip: Open folders in Sublime Text 2

In this post I will describe how you can add an item to the context menu in OS X for opening a folder in Sublime Text 2. Secondly we will make it easier to open a file or folder in Sublime from the terminal.

Start off by opening Automater, and create a new service. Now select “run shell script” from the second column on the left, and add the following code. Make sure your settings match the ones below.

/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl -n "$@"

Save the service, and note that the name you give it when saving is what it will be called in the context menu. If Sublime opens a blank window, toggle the sidebar, and you will see the documents.

Console

In order to simplify to process of opening a folder or file in Sublime from the terminal, you can run the command below. Note though, chances are that you have to run this command as sudo.

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

When this is done, you will be able to run Sublime simply by running the following:

#open current folder
subl .
#open specific folder
subl my-project/
#open file
subl index.php

I'm a webdeveloper based in Oslo, Norway. I currently work with web development at Nettmaker.

I would like to change the world, but they won't give me the source…

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments