Skip to content

Instantly share code, notes, and snippets.

@vincentmac
Created September 25, 2013 18:03
Show Gist options
  • Save vincentmac/6703537 to your computer and use it in GitHub Desktop.
Save vincentmac/6703537 to your computer and use it in GitHub Desktop.
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

awesome!

@larschinkel
Copy link

Thanks :)

@vsatyanaveen
Copy link

Thanks a lot

@willcharlton
Copy link

Awesome. Thanks!

@willcharlton
Copy link

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.

@mattobrien415
Copy link

Great, much appreciated!

@pierreprinetti
Copy link

👍

@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

Thanks!

@cleydyr
Copy link

cleydyr commented Aug 2, 2016

Worked for me as well. Thanks, man!

@sumeetadur
Copy link

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

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