Adding filetypes to Spotlight

From Mac Guides

Jump to: navigation, search


This tip requires
Mac OS X Tiger

By default, Spotlight doesn't index every file on your hard drive, and it's not very user friendly to add additional types. This guide details how to add files to the spotlight index.


Index Third-Party Filetypes

A growing list of applications have Spotlight plugins available for download. These plugings usually take the form of a package and install all the necessary files (in /Library/Spotlight)

Some Noteable Spotlight Plugins

For a complete list, see Apple's Spotlight download page

Index PHP files

This section illustrates, by example, how to add PHP files to your spotlight index.

The Property List Editor showing the new PHP entry
The Property List Editor showing the new PHP entry
  1. Install the developer tools
  2. In the finder, Go to "/Library/Spotlight" (command-shift-G)
  3. Control-click on SourceCode.mdimporter (which is there if you've installed the developer tools]] and show package contents
  4. Open Info.plist in (preferably) Property List Editor. Otherwise, you'll be editing XML in a text editor
  5. Add the following to Root->CFBundleDocumentTypes->0>LSItemsContentTypes
  6. Open Terminal and type
    mdimport -r /Library/Spotlight/SourceCode.mdimporter
  7. After a while, when Spotlight finishes reindexing, you'll be able to search inside PHP files.

Index c and c++ header files

  1. Open Terminal
  2. Type this:
   mdimport -f /usr/include
   mdimport -f /usr/local/include
   mdimport -f /System/Library/Frameworks