I know how to change default program to certain type of files, but I've been running to situations where I could use 2 defaults.

Lets take .html files for example. I have assigned Chrome to open all .html files on doubleclick, which is nice. As Im web developer, I usually need to open .html files also in textmate. For this to happen, I need to open context menu and select program from Open With menu.

Wouldn't it be great if one could Command+doubleclick to open that file with secondary program?

Is there a way to achieve this?

  1. Open Automator and choose the service template
  2. Set the input type to files or folders
  3. Add a run shell script action and choose to pass input as arguments
  4. Paste this as the script and edit the list of applications:

    applications="pdf Preview
    zip The Unarchiver"
    for f in "$@"; do
        if [[ "$ext" == "$basename" ]]; then
            app=$(grep -m1 ^$ext' ' <<< "$applications" | cut -d ' ' -f 2-)
        [[ -z "$app" ]] && app=TextMate
        open "$f" -a "$app"
  5. Assing the service a shortcut in the keyboard preference pane

There's a bug where the shortcuts for Automator services don't always work until the services menu has been shown once from the menu bar. Another bug is that services that receive folders or files as input aren't available when folders are selected in column view in Finder.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .