Question

It is possible using the right click menu on "Open With" to get the option to choose an application to open a certain file extension. You can then say "Always Open With This".

That works if the program is packaged as an OS/X bundle (which is actually a directory containing lots of stuff under the hood). But is there an easy way to make it so a regular console program could be used to open it by passing the file path as the first parameter on the command line?

Even if you turn on the "All Applications" it leaves Open grayed out on console programs.

Is this the kind of thing which would require an Automator script of some kind, or is there another way?

Was it helpful?

Solution

Create new application in automator

Locate "Run AppleScript" action and drag it to workflow area

Edit AppleScript:

on run {input, parameters}
    tell application "Terminal"
        activate
        do script with command "[YOUR_SHELL_COMMAND] " & (input as string)
    end tell
end run

Save it and use in "Open With" dialog

OTHER TIPS

Yes, you need to wrap the console program in something that turns it into a Mac app, Automator being the easiest way.

Select 'New' in Automator's File menu and create an application. Application's in Automator automatically receive the selected files and folders.

You just need a single Automator action, "Run Shell Script". The body of the action is the console command. You then set it to pass input as arguments.

Once you save it you can use it in an "Open With" dialog but you will have to browse to it using the "Other" selection.

http://duti.org: A command-line tool to select default applications for document types and URL schemes on Mac OS X.

See also: http://duti.org/documentation.html

Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top