Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent an application from being used as a default opener for ANY file?

MacOS is continually using Xcode to open various files in my OS. I already know how to set a default app opener for all files with a particular extension (.txt, .py, etc...), but I can't use this feature with "extensionless" files like .bash_profile. Is there a workaround for this other than changing the default app for each file?

My preferred solution would be if I could tell MacOS to never use Xcode as a default app opener. I'm assuming there is some config file buried away that might help me achieve this but I haven't been able to find anything to help me with this.

like image 968
Taylor Avatar asked Sep 19 '25 05:09

Taylor


2 Answers

Looking for the same I found this answer stop-xcode-from-hijacking-my-file-associations on apple.stackexchange.

It seems that XCode is pretty persistent but using this 3rd party app https://github.com/Lord-Kamina/SwiftDefaultApps you can achieve it!


Before; before, open file with xcode

After; after, open file with vs code


Instructions;

  • Step 1: After installing the app, go to System preferences > SwiftDefaultApps
  • Step 2: Go to the Uniform Type Identifiers tab and look for public data.
  • Step 3: Assign, under the Editor section, the desired editor.

look for public data

  • Step 4: Apply (the app is a little bit clumsy and sometimes it doesn't show the confirmation popup, if this is the case, just close the preference window, open it again and check that everything is ok!)
like image 152
mayo Avatar answered Sep 21 '25 01:09

mayo


Since asking this question, I stumbled upon this MacOS system file: ~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist

I've found that you can add your own dict entries into the LSHandlers array. For instance, I added the following entry to bind all public.data file types to my Sublime application:

<dict>
  <key>LSHandlerContentType</key>
  <string>public.data</string>
  <key>LSHandlerPreferredVersions</key>
  <dict>
    <key>LSHandlerRoleAll</key>
    <string>-</string>
  </dict>
  <key>LSHandlerRoleAll</key>
  <string>com.sublimetext.4</string>
</dict>
like image 43
Taylor Avatar answered Sep 21 '25 03:09

Taylor