MacOS – How to associate a file extension with a content type

filesystemfindermacosuti

I have some files with extension "module" and "inc," which are PHP files. When I try to open them, the list of applications that can open them shows only the application I have set as default application, even though there is another text editor that can open PHP files, and for which I have set the files with those extensions to be highlighted as PHP files are.

screenshot

If I open the "Get Info" dialog, select another application in "Open With," and then click on "Change All…" what I get is the following.

screenshot

screenshot

What I want to obtain is what shown in the following screenshot, which shows the "Open With" menu for another type of file:

screenshot

Is there a way to associate those extensions to the content type used for PHP files?
Alternatively, how can I show, in the list of the applications shown under the "Open With" menu, all the applications that can open PHP files, when Finder doesn't do that already?

I will explain what I want to obtain using a screenshot of RCDefaultApp.

screenshot

A file using "module" as extension is a PHP file, in my case (it is a Drupal module); what I want is adding that extension to the ones reported for the "public.php-script" UTI.

Best Answer

There is not a safe and advisable way to achieve what you are after because this function of the OS is controlled by the Launch Services database. Developers register the filetypes their applications support with the OS on first launch.

The best way to get this fixed is to petition the developer to add support for the file extension in a future version of their application.

With that said you have already found the only documented way that Apple offers for overriding the edicts of the Launch Services database. If you want to dig deeper and take the road less traveled supported here are a few pointers.

There is a .plist file that governs part of what Launch Services does located at: ~/Library/Preferences/com.apple.LaunchServices.plist

Apple notes that removing this plist can clear out unwanted Open With contextual menu options. But that's the opposite of what you're after.

It's a binary .plist but you could convert it to an xml version and experiment a little to see if you can come up with a recipe to achieve what you're after. This isn't advisable, it could cause harm, and it will most likely get overwritten by the OS at some point.

There is also a tool hidden a bit deeper in the OS called lsregister which could be helpful in exploring Launch Services's plumbing. Here is a helpful explanation of lsregister and its options.