Skip to content

Instantly share code, notes, and snippets.

@gonzaloamadio
Forked from hellysmile/mac_clean.sh
Created April 30, 2021 15:57
Show Gist options
  • Save gonzaloamadio/33d3322dc603f17515da5d21b9ae022f to your computer and use it in GitHub Desktop.
Save gonzaloamadio/33d3322dc603f17515da5d21b9ae022f to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
log() { echo -e "\e[0;33m${1}\e[0m"; }
# Ask for the administrator password upfront.
sudo -v
log 'Empty the Trash on all mounted volumes and the main HDD...'
sudo rm -rfv /Volumes/*/.Trashes
sudo rm -rfv ~/.Trash
log 'Clear System Log Files...'
sudo rm -rfv /private/var/log/asl/*.asl
sudo rm -rfv /Library/Logs/DiagnosticReports/*
sudo rm -rfv /Library/Logs/Adobe/*
rm -rfv ~/Library/Containers/com.apple.mail/Data/Library/Logs/Mail/*
rm -rfv ~/Library/Logs/CoreSimulator/*
log 'Cleanup iOS Applications...'
rm -rfv ~/Music/iTunes/iTunes\ Media/Mobile\ Applications/*
log 'Remove iOS Device Backups...'
rm -rfv ~/Library/Application\ Support/MobileSync/Backup/*
log 'Remove iOS Software Updates...'
rm -rfv ~/Library/iTunes/iPhone\ Software\ Updates/*
log 'Cleanup XCode Derived Data and Archives...'
rm -rfv ~/Library/Developer/Xcode/DerivedData/*
rm -rfv ~/Library/Developer/Xcode/Archives/*
log 'Cleanup Homebrew Cache...'
brew cleanup --force -s
rm -rfv $(brew --cache)/*
brew tap --repair
# Revoke sudo access again.
sudo -k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment