Default editor for files without file name extension in Mac OS X

Solution 1:

You need to change the editor for the text/plain mime type or public.plain-text UTI. The regular Get Info dialog changes the association for the file name extension, which these files don't have.


Get RCDefaultApp and install it.

Open System Preferences » Default Apps » Apps. Select your desired default editor, and look for either of the above in the application's list of supported types.

alt textalt textalt text

Select the entry, and click Set as Default. You're done. Both opening from Finder and the command-line open will open your new default editor.


This also changes all .txt files and the like. I don't think this can be prevented, since OS X thinks both these and extension-less files are public.plain-text/text/plain.


To do this without RCDefaultApp, edit Edit ~/Library/Preferences/com.apple.LaunchServices.plist.

Add an entry under LSHandlers, containing the UTI (key LSHandlerContentType, e.g. public.plain-text) and application bundle identifier (LSHandlerRoleAll, e.g. com.macromates.textmate).

It looks like this in Property List Editor:

alt textalt text

Solution 2:

You can also run plutil -convert xml1 ~/Library/Preferences/com.apple.LaunchServices.plist and add something like this:

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

You can apply changes by restarting or by rebuilding the Launch Services database. Logging out and back in isn't enough.

Or add this to a duti configuration file:

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

public.plain-text also includes files with a .txt or .text extension. I don't know any way to change the default application for files with arbitrary extensions.

public.unix-exexutable includes executable scripts without a filename extension. If you try to change the default application for them from Finder, there is an error like this:

The operation can’t be completed.

An unexpected error occurred (error code -50).

Solution 3:

RCDefaultApp is sadly no longer available, but SwiftDefaultApps is a modern replacement. It does not list MIME types, but I found that changing public/data on the "Uniform Type Identifiers" pane did the trick for files without an extension.