Markdown Indexing in OS X Spotlight Search
You can do this without disabling SIP by creating a copy of the system RichText.mdimporter, modifying its Info.plist and saving it in /Library/Spotlight.
cp -r /System/Library/Spotlight/RichText.mdimporter ~/
(This copies the .mdimporter to the root of your user home directory)- You can either use an editor from the command line or go to a Finder window in your Home folder and do a “Show Package Contents” on the RichText.mdimporter file bundle to get to the Info.plist file and open it with ‘Text Edit’ or any Plain Text Editor.
Inside RichText.mdimporter/Contents/Info.plist, add:
net.daringfireball.markdown
to the array of LSItemContentTypes in that file as shown here:
Rename the RichText.mdimporter to Markdown.mdimporter:
mv ~/RichText.mdimporter Markdown.mdimporter
Copy the new .mdimporter to /Library/Spotlight:
sudo cp -R ~/Markdown.mdimporter /Library/Spotlight
Use the mdimport command to add it to the metadata indexing system:
mdimport -r /Library/Spotlight/Markdown.mdimporter
This command asks the server to reimport files for UTIs claimed by the listed plugin.
It should re-import the files automatically after the previous caommand, but if you wish, you can always re-index the whole drive to include the new filetype by rebuilding the whole Spotlight index:
sudo mdutil -E /
(Note: This will take some time, and is rather resource heavy…)
Now you should be good to go with .markdown files being indexed by Spotlight!