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\ Text.app/Contents/SharedSupport/bin/subl -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.