Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
“Open in Sublime Text” in macOS context-menu

This list has been updated for Big Sur (and later). Since I don't use these versions, this guide might still need further improvements. For older macOS versions, please see this older revision.

Open in Sublime Text

  • Open Automator
  • Quick Action
  • Set “Service receives selected” to files or folders in any application
  • Add a Run Shell Script action
  • 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

Add to Sublime Text

Let's repeat the steps above for a second entry, this time to add files or folders to an existing Sublime Text window

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

Keyboard Shortcuts

You can assign a global shortcut to run the services we just created

  • Open “System Preferences”
  • Select “Keyboard” then the “Shortcuts” tab
  • In the left pane, click on “Services”
  • In the right pane, scroll to “Files and Folders”
  • Select “Open in Sublime Text” (or “Add to Sublime Text”) and click “add shortcut”
  • Select a shortcut

Edit Context Menu items

You might want to rename or edit the items we just created

  • Activate Finder
  • Click on “Finder” in the Apple menu, select “Services” then “Services Preferences”
  • In the right pane, scroll to “Files and Folders” and scroll to the item you want to edit
  • Right click the item and select “Open in Automator”
  • Edit and save

Alternatively, you can edit the workflow (e.g. ~/Library/Services/Open in Sublime Text.workflow) in your preferred text editor

@MajoroMask
Copy link

MajoroMask commented Jun 30, 2021

In macOS Big Sur the Automator option to "Create a new Service" is replaced with "Quick Action"
I had to look other places in automator for the "Create a new Service" option in confusion

And the Service receives selected have been changed into Workflow receives current, like this:

image

@idleberg
Copy link
Author

idleberg commented Jun 30, 2021

@ahmu83 @MajoroMask Thanks for the input, I've updated the gist accordingly

@IngFrustrado
Copy link

IngFrustrado commented Jul 6, 2021

In macOS Big Sur the Automator option to "Create a new Service" is replaced with "Quick Action"
I had to look other places in automator for the "Create a new Service" option in confusion

And the Service receives selected have been changed into Workflow receives current, like this:

image

I tested it for macOS Bigsur, it works.

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