A lightweight, interactive Zsh shell script designed to reclaim disk space on macOS by purging unnecessary caches, temporary build files, and legacy backups.
- Interactive Menu: Choose specifically what you want to clean.
- Developer Focused: Dedicated options for Xcode, Android Studio, and JetBrains/GoLand environments.
- Browser Maintenance: Clears cache for Chrome, Safari, Firefox, Edge, and Brave.
- Safety First: Uses
setopt nullglobto prevent script errors when folders are already empty. - Disk Summary: Displays a quick overview of your storage before you start.
| Option | Target | Description |
|---|---|---|
| 1 | User Caches | General application caches in ~/Library/Caches. |
| 2 | Xcode DerivedData | Clears build artifacts and indexes (safe to delete). |
| 3 | Xcode Archives | Removes old app builds/archives. |
| 4 | iOS Backups | Deletes local iPhone/iPad backups from MobileSync. |
| 5 | Android/Gradle | Clears Gradle daemons, caches, and Android Studio build data. |
| 6 | Web Browsers | Wipes cache for all major browsers. |
| 7 | JetBrains/GoLand | Clears IDE caches (keeps your settings/configs intact). |
| 8 | Trash | Empties the user's trash bin. |
| 9 | SAFE Summary | A "one-click" batch run of options 1, 5, 6, 7, and 8. |
- Save the script as
mac_cleanup.zsh. - Make it executable:
chmod +x mac_cleanup.zsh
- Run the script:
./mac_cleanup.zsh
```
---
## β οΈ Requirements
* **OS:** macOS
* **Shell:** Zsh (default on macOS Catalina and later)
* **Permissions:** The script runs in user-space. If you need to delete system-level caches, you may need to run it with `sudo`, though it is currently optimized for user-level data.
---
## π Disclaimer
> [!CAUTION]
> This script uses `rm -rf`. While the paths are targeted at cache and temporary directories, ensure you have backups of important data. Specifically, **Option 4** will delete your local iOS device backups. Use with care!