Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 0 down vote accepted
  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
        basename=${f%/}
        basename=${basename##*/}
        ext=${basename##*.}
        if [[ "$ext" == "$basename" ]]; then
            app=
        else    
            app=$(grep -m1 ^$ext' ' <<< "$applications" | cut -d ' ' -f 2-)
        fi
        [[ -z "$app" ]] && app=TextMate
        open "$f" -a "$app"
    done
    
  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.

share|improve this answer
    
fits my needs perfectly, thanks! –  Tom Oct 8 '12 at 9:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.