- Open Automator
- Create a new Service
- Set “Service receives selected” to
files or folders
inany application
- Add a
Run Shell Script
action - Set the script action to
/usr/local/bin/atom -n "$@"
- Set “Pass input” to
as arguments
- Save as
Open in Atom
Let's repeat the steps above for a second entry, this time to add files or folders to an existing Atom window
- Open Automator
- Create a new Service
- Add a
Run Shell Script
action - Set “Service receives selected” to
files or folders
inany application
- Set the script action to
/usr/local/bin/atom -a "$@"
- Set “Pass input” to
as arguments
- Save as
Add to Atom
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 Atom” (or “Add to Atom”) and click “add shortcut”
- Select a shortcut
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 Atom.workflow
) in your preferred text editor
@idleberg
Do you know how to script the whole process?
For example, if preparing a PyQt5 app to install on Mac, I'd like to include a script that will add 'open with my app' to the finder context menu for certain file types. Doesn't matter if the user has to manually run the script, as long as it's simple for them.
For Windows I do it by adding items to the registry, which is scriptable in several ways (including a python winreg module).
For macOS, searching for an hour has found only GUI methods similar to yours, except at developer.apple.com.
Maybe the info I need is in one of the follwing areas,
but after looking through them for several minutes I didn't see anything obvious:
https://developer.apple.com/documentation/automator
https://developer.apple.com/documentation/installerjs