Skip to content

Instantly share code, notes, and snippets.

@terwey
Created January 12, 2021 14:42
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 terwey/f1ba29077a4ea765e810228b4ad64aae to your computer and use it in GitHub Desktop.
Save terwey/f1ba29077a4ea765e810228b4ad64aae to your computer and use it in GitHub Desktop.
macOS mds exclusion list

For some reason macOS reindexes a file if it was read or opened by another program, so cache dirs are heavy offenders. Can be checked with sudo fs_usage mdworker mds

A list to start with, you can add these paths by going to System Preferences then Spotlight and finally Privacy, clicking the + and then doing cmd+shift+g or programatically (see below).

My current list contains the following sudo defaults read /System/Volumes/Data/.Spotlight-V100/VolumeConfiguration.plist Exclusions

NB: Change the /Users/yt to reflect your OWN user.

(
    "/Applications/Slack.app/Contents",
    "/Library/Application Support/com.eset.remoteadministrator.agent",
    "/Library/Application Support/org.pqrs",
    "/Users/yt/Library/Application Support/Code/",
    "/Users/yt/Library/Application Support/Google",
    "/Users/yt/Library/Application Support/Slack",
    "/Users/yt/Library/Containers/com.apple.Safari/Data/Library/Caches",
    "/private/var/log",
    "/private/var/logs"
)

Adding a new one is done by sudo defaults write /System/Volumes/Data/.Spotlight-V100/VolumeConfiguration.plist Exclusions -array-add '/Users/yt/Library/Application\ Support/Code/'

and then you have to restart MDS: sudo launchctl stop com.apple.metadata.mds && sudo launchctl start com.apple.metadata.mds

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