Useful macOS defaults: Spotlight

Spotlight settings are split across com.apple.Spotlight (what Spotlight searches) and the mdutil command-line tool (controlling the index itself).

Turn off Spotlight Suggestions and Bing web results

Stop Spotlight from sending your searches to Apple and showing web results:

defaults write com.apple.Spotlight orderedItems -array \
  '{"enabled" = 1;"name" = "APPLICATIONS";}' \
  '{"enabled" = 1;"name" = "MENU_EXPRESSION";}' \
  '{"enabled" = 1;"name" = "CONTACT";}' \
  '{"enabled" = 1;"name" = "MENU_CONVERSION";}' \
  '{"enabled" = 1;"name" = "MENU_DEFINITION";}' \
  '{"enabled" = 1;"name" = "DOCUMENTS";}' \
  '{"enabled" = 1;"name" = "EVENT_TODO";}' \
  '{"enabled" = 1;"name" = "DIRECTORIES";}' \
  '{"enabled" = 1;"name" = "FONTS";}' \
  '{"enabled" = 1;"name" = "IMAGES";}' \
  '{"enabled" = 1;"name" = "MESSAGES";}' \
  '{"enabled" = 1;"name" = "MOVIES";}' \
  '{"enabled" = 1;"name" = "MUSIC";}' \
  '{"enabled" = 1;"name" = "MENU_OTHER";}' \
  '{"enabled" = 1;"name" = "PDF_DOCUMENTS";}' \
  '{"enabled" = 1;"name" = "PRESENTATIONS";}' \
  '{"enabled" = 1;"name" = "SPREADSHEETS";}' \
  '{"enabled" = 1;"name" = "SYSTEM_PREFS";}' \
  '{"enabled" = 0;"name" = "MENU_SPOTLIGHT_SUGGESTIONS";}' \
  '{"enabled" = 0;"name" = "MENU_WEBSEARCH";}'

The last two lines turn off Spotlight Suggestions and web search results. You can also turn off any other category by setting its enabled to 0.

After running this, reload the Spotlight settings:

killall mds > /dev/null 2>&1

You can also control this in System Settings, then Spotlight by unticking search categories.

Manage the Spotlight index with mdutil

Check whether indexing is turned on for a volume:

mdutil -s /

Turn off indexing for a volume:

sudo mdutil -i off /Volumes/MyDrive

Turn indexing back on:

sudo mdutil -i on /Volumes/MyDrive

Rebuild the Spotlight index (useful if search gives wrong results):

sudo mdutil -E /

Turn off indexing across the whole system:

sudo mdutil -a -i off

This breaks Spotlight search, Finder search, Mail search, and Siri knowledge. Only do this if you have a good reason.

Exclude folders from Spotlight

You can add folders to the Spotlight privacy list (folders that Spotlight will not index):

Through the command line, add to the privacy list in System Settings, then Spotlight, then Privacy. There is no clean single defaults command for this. The simplest approach is through System Settings.

You can also create a .metadata_never_index file in any folder to stop Spotlight from indexing it:

touch /path/to/folder/.metadata_never_index

Change the Spotlight keyboard shortcut

The default shortcut is Command Space. You can change it in System Settings, then Keyboard, then Keyboard Shortcuts, then Spotlight.

Read current Spotlight settings

defaults read com.apple.Spotlight

Enjoyed this post?

Well, you could share the post with others, follow me with RSS Feeds and/or send me a comment via email.


Tags

Category:

Year: