How does Apple associate file type with (external) applications

applications

I have texlive and texshop for Latex on my external SSD. I deleted my Library preference files for both apps along with a lsregister -kill command to force my Mac to forget all non-default pathing.

But somehow Mac still recognizes to associate .tex file types as a Latex file. Reason I know this is because when I have my SSD unplugged, my .tex file shows the unknown application file icon but as soon as I plug my SSD, the file icon changes to a Latex file icon.

How can I force my Mac to forget all file associations except the default file types (e.g., .pdf, .txt, etc)? I'd like to see a 'Cannot open this file' window when I click a .tex file.

Best Answer

You can find a work-around described here:

https://www.cnet.com/news/how-to-clear-custom-application-associations-in-os-x/

The steps required are:

  1. Locate a .tex file on your system in the Finder and press Cmd-i to open the info window

  2. In the "Open With" section, you'll see a drop-down. Choose "Other" and then select the built-in Calculator.app to open the file with. This is done as Calculator.app does not support opening any document type.

  3. In the info window press "Change All..." so that all .tex files becomes associated with Calculator.app.

  4. If you try opening a .tex file now, you'll get an error saying that Calculator.app cannot open this file type.

  5. Open Terminal.app and run the following command:

    $(locate lsregister | grep '^\/System') -u /Applications/Calculator.app
    

This command first finds the lsregister program on your system, and then runs it to unregister (i.e. clear any document type associations) for the Calculator.app.

Now when you open .tex files, you'll be presented with the default popup saying that the file cannot be opened, and you'll be asked to choose an application to open it with.