Stop indexing your development directory

Are you a software developer?

Do you run macOS?

Do you frequently checkout files from third party code repositories?

Do you use an IDE like PHPStorm, Xcode, Atom, Netbeans, or something else?

Do you frequently run commands like npm install that reach out to the web and pull down a bajillion files you will literally never-ever open even if your life depended on it?

I do… and that’s why I block macOS Spotlight from indexing the parent directory to all of those files. It’s a dead simple and obvious thing to do once you think of it.

  • Your IDE already indexes all of the files in your project, to help with things like code completion and linting
  • All of the code you write is probably accessed only through your IDE, and probably not through Finder
  • If you’re like me, you work on several projects at once, between several branches, multiple checkouts, with differing milestones, but largely related to one central codebase, so having a Spotlight index is mostly useless when there is so much content duplication
  • Spotlight usually ignores hidden . files, but that still leaves node_modules exposed, and you can’t tell it to ignore a directory name – only the contents of specific directories
  • Battery life is a precious commodity, so don’t waste it indexing files you don’t need indexed

To remove your directory from Spotlight:

  • Open System Preferences
  • Click “Spotlight” in the top row on the right
  • Click to the “Privacy” tab
  • Click the “+” on the lower left
  • Choose the directory your code is in (mine is: ~/Documents/Development/)
  • I added my Downloads directory here, because it tends to be an accidental graveyard of stuff that I use once and forget to delete, so I don’t see the need to index it myself
  • Enjoy a faster computer, improved battery life, shinier hair, and smoother skin (probably not the last two 🧡)