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 "$@"
[retina_image id=”1158″ full_width=”false”]
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.
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