Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sublime Text OSX Context Menu

Add Sublime Text to OS X Context Menu

  • Open Automator
  • Create a new Service
  • Add a Run Shell Script action
  • Set input to Service receives selected files or folders in any application
  • Set the script action to /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -n $@
  • Set Pass input to as arguments
  • Save as Open in Sublime Text
@kakulukia
Copy link

kakulukia commented Oct 22, 2014

awesome!

@larschinkel
Copy link

larschinkel commented Dec 19, 2014

Thanks :)

@vsatyanaveen
Copy link

vsatyanaveen commented Jan 13, 2015

Thanks a lot

@willcharlton
Copy link

willcharlton commented Jan 20, 2015

Awesome. Thanks!

@willcharlton
Copy link

willcharlton commented Jan 20, 2015

For my environment, I needed to wrap $@ in quotes

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

or else it opened up a bunch of nonsense when the path contained whitespace.

@mobbSF
Copy link

mobbSF commented Feb 14, 2015

Great, much appreciated!

@pierreprinetti
Copy link

pierreprinetti commented Aug 6, 2015

👍

@alexya
Copy link

alexya commented May 27, 2016

It can't work to me.
When I right click a .py file from Finder or Desktop, there is no menu/sub-menus named like "Open in Sublime Text".
I don't know what I missed.

@frgooall
Copy link

frgooall commented Jul 7, 2016

Worked for me..thanks!

@JoeDorseyJr
Copy link

JoeDorseyJr commented Jul 31, 2016

Thanks!

@cleydyr
Copy link

cleydyr commented Aug 2, 2016

Worked for me as well. Thanks, man!

@sumeetadur
Copy link

sumeetadur commented Aug 29, 2016

Thank you!

@ismnoiet
Copy link

ismnoiet commented Nov 8, 2016

@vincentmac what if i want "Open in Sublime Text" to appear at the top level context menu and not under the "services" item,
thanks in advance.

@suvradip
Copy link

suvradip commented Mar 12, 2017

great

@mi-lee
Copy link

mi-lee commented Aug 19, 2017

you can also do this if you want to open the parent directory of the selected file:

FOLDER="$(dirname "$@")"
/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -n $FOLDER

@roblav96
Copy link

roblav96 commented Dec 15, 2018

Requirement -> /bin/bash

Originally tried /usr/bin/zsh but that threw errors.

@leoblum
Copy link

leoblum commented Jan 22, 2021

For my environment, I needed to wrap $@ in quotes

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

or else it opened up a bunch of nonsense when the path contained whitespace.

Thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment