How to add “Open in Sublime Text” service to any folder or a file on Mac – Shell Script

Hello everyone,

I have been using the sublime text lately. I am amazed with several jaw dropping features this gorgeous editor provides. I will writing more on sublime text and today  I am going to discuss about “How to add a service ‘Open in Sublime Text‘ as a service using a shell script on the Mac”. Its pretty simple and we will be using the Automator application to do this.

Step 1: Fire up the Automator application which is a native Mac application. Go to “File” menu and click on “New

Step 2: Select the type of the document as “Service” from the menu.

Step 3: In the search bar, type “Shell” it should “Run Shell Script“. Select it and drag it into the adjacent window.

Step 4: You will see a selection with text area. Copy the path of Sublime Text and paste it. The path of the Sublime executable file is:


Step 5: You can get this path by going to the Sublime Text app and right click on it and choose “Show package contents

Step 6: Now add -n $@ after the path which should look the following :

/Applications/Sublime\ -n $@

Step 7: Select “/bin/zsh” and “as arguments” from the Shell and Pass input drop downs respectively.

Step 8: Now, select “Files and Folders from the drop down menu saying “Service receives selected” and save it as “Open in Sublime Text

Step 9: Close the Automator and go to any folder and right click on it and under Services sub-menu you can see Open in Sublime Text.

I have attached the screen-shots for much more clarity.

S1 S2 S3 S4 S5 S6 S7 S8 S9


The End 🙂





  1. Thanks. Was trying to do the same thing, but it failed as I didn’t select pass as arguments … Why use/change to zsh? Doesn’t seem to make a difference.(?)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s