Beyond Storage: Optimizing Your Development Environment via Mole
You're asking about Mole (tw93/Mole), a specialized shell script designed to deep clean and optimize macOS. For us engineers, a cluttered system isn't just a storage issue—it can lead to slow build times, weird caching bugs, and a general "lag" that kills productivity.
Here’s a breakdown of why this tool is a gem for your workflow.
Think of Mole as a "Spring Cleaning" script for your terminal. While regular users might just care about disk space, engineers benefit from
Clearing Build Artifacts
It targets node_modules, Cargo registries, and DerivedData (if you do iOS/macOS dev), which can grow to dozens of gigabytes.
System Snappiness
By clearing system-level caches and flushing DNS, it ensures your environment stays predictable.
Automation
Instead of manually running five different commands to free up space, you run one script.
Mole is designed to be lightweight. You don't even strictly need to "install" it as a package; you can run it directly or alias it.
You can run it directly using curl. This is perfect if you just want a one-time clean
curl -s https://raw.githubusercontent.com/tw93/Mole/master/mole.sh | bash
If you want to use it regularly, I recommend downloading the script and adding it to your .zshrc or .bash_profile.
Clone or download the script
mkdir -p ~/scripts
curl -o ~/scripts/mole.sh https://raw.githubusercontent.com/tw93/Mole/master/mole.sh
chmod +x ~/scripts/mole.sh
Add an alias to your configuration
Open your ~/.zshrc and add
alias cleanup='~/scripts/mole.sh'
Reload your shell
source ~/.zshrc
Now, whenever your Mac feels a bit sluggish, you just type cleanup in your terminal!
Mole is essentially a collection of rm -rf and system maintenance commands. If you were to look at a simplified version of what it does, it looks something like this
#!/bin/bash
echo " Starting deep clean..."
# Clear macOS System Caches
sudo rm -rfv ~/Library/Caches/*
# Clear Homebrew Caches (The big one for devs!)
brew cleanup -s
rm -rf $(brew --cache)
# Clear Xcode DerivedData (If you're an Apple dev)
rm -rf ~/Library/Developer/Xcode/DerivedData/*
# Flush DNS
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
echo " System optimized!"
Read the script first
As a rule of thumb, never pipe a script from the internet directly into bash without reading it. You can check the source at tw93/Mole.
First Run
The first time you run it, you might be surprised by how much space you recover (sometimes 20GB+ if you use Docker or Homebrew heavily).
Customization
Since it's just a shell script, feel free to fork it and add your own paths, like cleaning up specific project dist folders or log files.