I looked at my free disk space and I was like What the f*ck?!

Quickly I decided to Erase them all and reclaim my space. 🤟

Here is how.

1. Homebrew users

Get rid of old homebrew packages by running brew cleanup. You might want to update homebrew itself and your packages via brew update && brew upgrade while you’re at it.

2. RVM users

Uninstall old rubies you no longer use via rvm uninstall <ruby> and cleanup all the junk by running rvm cleanup all.

3. Docker users

List your docker images via docker images, remove the one you don’t use by running docker image rm <image:tag> and finally nuke all the rest with docker system prune.

4. Logs

You can delete logs from given directory and subdirectories with find . -type f -name '*.log' -delete -print (print added for verbosity). I recommend running it in /usr/local/var/log as well.

5. JS developers

You might want to delete node modules from your old projects as well - find . -name 'node_modules' -delete -print. Bye bye modules.

6. Git users

To aggressively garbage collect all repos (recursively), you can try running this in your projects directory: find . -name '.git' -print -execdir sh -c 'cd {} && git gc --aggressive --prune' \;

Note: with aggressive flag it might take a while if you have a lot of repositories (or few really big ones).

7. Ruby developers

You might want to nuke gems bundled to vendor/ in your old projects by:

find . -wholename '*/vendor/bundle' -exec rm -rf "{}" \;
find . -wholename '*/vendor/ruby' -exec rm -rf "{}" \;
8. Going further

You can use tools like Disk Drill to visualize disk usage and track down more useless stuff that occupies your disk.

I’m happy to say to I managed to reclaim almost 30GB of disk space after going through all the process.