Saturday, 9 March 2019

macos - OSX 'open with' bash script


I've got a bash script, potentially many of them in fact, which I'd like to be able to open files in OSX's finder with.


It's a really, really simple concept but for some reason bash scripts are greyed out in the finder 'open with' dialog.


I gather that there are various ways of using applescript or packaging as an app... but I haven't been able to figure any of this out and I don't really want to have to pick up another language just for this trivial task - could someone spoon feed me how to do this?


Thanks!



Answer



It's not possible. Launch Services works with application identifiers, and bash scripts don't have them.


You need to create a wrapper application using Automator.



  1. Launch Automator

  2. Select Application

  3. Look for the Run Shell Script action and add it to the right.

  4. Pass input as arguments

  5. Put your script in there

  6. Save somewhere


Here's my version, using the Growl command line utility:


enter image description here


Result:


enter image description here




You can see the effect this change has on ~/Library/Preferences/com.apple.LaunchServices.plist when you Change All:


enter image description here


("Test" is the name I gave my Automator application)


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...