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.

When double clicking an executable file (without a file extension) in Finder, it opens in Terminal by default. I can change that to any other application for this single file, but I cannot change the default for all files.

Is there any way to do that?
I never want to open executable files in Terminal, and I'm missing that functionality since NeXTStep, which had a hidden default for that.

share|improve this question
    
What version of the OS are you running? Sadly, the answer will be much easier if you're pre-Snow Leopard. –  Daniel Lawson Sep 26 '11 at 19:01
    
Snow Leopard :) Why, how would it work on Leopard? –  marc.guenther Sep 27 '11 at 8:59
1  
Prior to SL, Finder used creator codes as part of its policy to determine which app was bound to a particular kind of file, so binding extensionless files to a particular app would be easier if they shared a creator code. Starting with SL, Finder ignores creator codes and looks primarily to file extension, which is obviously an issue for files that have no extension. See daringfireball.net/2009/10/congrtlns-osx for a further discussion. :-( –  Daniel Lawson Sep 27 '11 at 12:04
add comment

2 Answers 2

up vote 2 down vote accepted

Run plutil -convert xml1 ~/Library/Preferences/com.apple.launchservices.plist and add an entry like this under LSHandlers:

<dict>
    <key>LSHandlerContentType</key>
    <string>public.unix-executable</string>
    <key>LSHandlerRoleAll</key>
    <string>com.macromates.textmate</string>
</dict>

You can also change the default application for normal files with no extension:

<dict>
    <key>LSHandlerContentType</key>
    <string>public.plain-text</string>
    <key>LSHandlerRoleAll</key>
    <string>com.macromates.textmate</string>
</dict>

You can apply the changes by restarting. Just logging out and back in doesn't seem to work. You could also rebuild the Launch Services database, but it has the side-effect that the warnings about opening applications for the first time are shown again.

Another option is to add something like this to a duti configuration file:

com.macromates.textmate public.unix-executable all
com.macromates.textmate public.plain-text all

To make this question more searchable, here is the error message Finder shows when you try to change the default application for executable scripts:

The operation can’t be completed.

An unexpected error occurred (error code -50).

share|improve this answer
    
That worked fine! I had to logout and log back in so that Finder picks up the change. –  marc.guenther Nov 15 '12 at 14:26
    
I use "duti" for this exact purpose (as proposed by Lauri) and it works great. Note that you can skip the configuration file and set the viewer with a single command: duti -s com.macromates.textmate public.unix-executable all –  John Hart Aug 1 '13 at 22:58
add comment

What you'd need to do, is go to the file, control click, and select "Get info". In the info window, there is a section called Open With, you will find a drop-down box and a button that says Change All. That button should change all documents' default app to whatever you choose.

Open With...

If you don't have the permissions to modify the file, OSX will automatically prompt you to change it on all files of the same kind. Im in Snow Leopard 10.6.8, and it works: tried it with bash, shell, and sh files.

Hope it helps!

share|improve this answer
3  
Sorry, I forgot to mention that I have files with no file extension. Your answer works for .sh files for example, but I have several others, like 'git-setup-hooks' for example. –  marc.guenther Sep 27 '11 at 8:58
add comment

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.