1

I'm trying to set SublimeText as the default editor for any unknown extension.

I'm aware that I can define the opening application for a given extension, but I would like to set a default application for the case the extension is unknown (which happens a lot if you name your files extensions manually).

The obvious solution in my case is rather to name the new files with a known extension like txt, but just for the sake of knowing whether or not it's possible to have a default application for all, I was looking for the LSHandlerContentType key in google and couldn't find any apple documentation page explaining what this key does.

So my question is: where is the LSHandlerContentType's official documentation page?

(I tried google without success)

1 Answer 1

2

LSHandlers are set per content-type for the individual items. There isn't a catchall. You'll need to run mdls on one and see what kMDItemContentType is and set the LSHandler appropriately with something along the following vein:

defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=xxxType;LSHandlerRoleAll=xxx.yyy.sublime;}' 

For example, if the content type is a plain text file, it'd be as follows:

defaults write com.apple.LaunchServices LSHandlers -array-add {LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.2;}

You can review more information on the lsregister here: http://krypted.com/mac-security/lsregister-associating-file-types-in-mac-os-x/

1
  • Massive thanks for mentioning the tool mdls for getting the ContentType! Now I know how to fish.
    – Lord Zsolt
    Nov 27, 2022 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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