User Tools

Site Tools


osxspotlighttex

Configuring Spotlight to index TeX files

If you've found yourself unable to search for text contained inside .tex files through OS X spotlight, here is a solution:

Go here and download the TeX mdimporter (direct download link) An mdimporter is a plugin that tells Spotlight how to index a specific file type.

To install the mdimporter, extract the archive into the directory ~/Library/Spotlight:

$ mkdir ~/Library/Spotlight   # (if the directory doesn't exist yet)
$ tar xvfz TeX.mdimporter.tgz -C ~/Library/Spotlight

Now you have to let OS X know about the new mdimporter. To do so, open a terminal window and enter:

$ mdimport -r ~/Library/Spotlight/TeX.mdimporter

To make sure everything is indexed, you may want to restart your computer. Also, to tell spotlight explicitly to add all .tex files in a directory (and its subdirectories), you can use the following command:

$ find <directory where tex files reside> -name '*.tex' | xargs -n1 mdimport

Example:

$ find /Users/marius/Work -name '*.tex' | xargs -n1 mdimport
osxspotlighttex.txt · Last modified: 2008/02/12 14:08 by kleiner