Skip to content

Instantly share code, notes, and snippets.

@zsiddiqi
Forked from gereon/gist:3150445
Created May 10, 2020 04:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zsiddiqi/0d268d9e017a1b88c8a0fa9c18aaf3a7 to your computer and use it in GitHub Desktop.
Save zsiddiqi/0d268d9e017a1b88c8a0fa9c18aaf3a7 to your computer and use it in GitHub Desktop.
Mac OSX Spotlight Enhancement

Mac OSX Spotlight Enhancement

Add this to Info.plist in /System/Library/Spotlight/RichText.mdimporter/Contents/ and Spotlight will search for source code files.

<string>public.c-header</string>
<string>public.c-plus-plus-header</string>
<string>public.c-source</string>
<string>public.objective-c-source</string>
<string>public.c-plus-plus-source</string>
<string>public.objective-c-plus-plus-source</string>
<string>com.sun.java-source</string>
<string>public.perl-script</string>
<string>public.python-script</string>
<string>public.csh-script</string>
<string>public.shell-script</string>
<string>public.ruby-script</string>
<string>public.php-script</string>
<string>com.netscape.javascript-source</string>
<string>net.daringfireball.markdown</string>

To find the entry for other file extensions do:

mdimport -n -d1 somefile.ext

After adding the desired file types you have to run

mdimport -r /System/Library/Spotlight/RichText.mdimporter

to update the new file extensions.

To re-index the HD you can run

sudo mdutil -E /

To implement an easy command to search via the Terminal using Spotlight install spotfind.sh from https://github.com/mattheworiordan/Mac-OS-X-Useful-Scripts

To add system folders to the search index use the script above and execute

spotfind -c

More Information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment