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 want to open all makefiles with TextWrangler. But since makefiles have no suffix so binding a type of file to TextWrangler does not work.

How can I tell Mac to open any file named Makefile with TextWrangler?

share|improve this question
add comment

3 Answers 3

There is no way to do this, you can change the application opened on a per instance basis using the standard methods, however this will not apply to all other files of the same name.

There are two workarounds, but those do involve a slightly more user movements, click->mouse move ->click) instead of double-click

  1. TextWrangler adds an menu item to the right click (ctrl-left click) menu for all files to "Open File in TextWrangler"
  2. Drag the files into the TextWrangler app (or a shortcut) to open the files directly.
share|improve this answer
add comment

I don't know any way to change the default app based on filename, but you could assign a default application for text files with no extension (and executable shell scripts). f=~/Library/Preferences/com.apple.launchservices.plist; plutil -convert xml1 $f; open $f -a TextEdit and add the entries below to the LSHandlers array:

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

Applying the changes requires restarting the OS (not just logging out and back in).

share|improve this answer
add comment

There is a way, but I wonder if LaunchSerivces would honor it on Lion or not.

Any how, it is setting the file's creator & type code.

I read some time ago that Lion's LaunchServices no longer honors those codes and they are Legacy tech from the old Mac days.

I can think of one possible solution for this. That is to change, if that is even possible, the kMDItemContentType to have a type unique to Makefile's. Also that type must be some how constructed and listed in the field below that which is kMDItemContentTypeTree. You can lookup those fields while running % mdls Makefile in Terminal.app.

Either way, setting the creator & type codes or setting kMDItemContentType field, is not an easy task. But I hope I have put you on the right track for a possible solution.

share|improve this answer
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.