Skip to content

Instantly share code, notes, and snippets.

@NeQuissimus
Forked from ClarkGoble/regularmaint.sh
Last active December 14, 2015 03:29
Show Gist options
  • Save NeQuissimus/5021627 to your computer and use it in GitHub Desktop.
Save NeQuissimus/5021627 to your computer and use it in GitHub Desktop.
#!/bin/bash
# get rid of duplicate apps by reindexing
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
# reindex mail
#rm "$HOME/Library/Mail/v2/MailData/Envelope Index"
#rm "$HOME/Library/Mail/v2/MailData/Envelope Index-shm"
#rm "$HOME/Library/Mail/v2/MailData/Envelope Index-wal"
# Vacuum instead of removal
sqlite3 "$HOME/Library/Mail/V2/MailData/Envelope Index" vacuum
# cleanup downloaded mail attachments (you can always redownload later)
rm -r "$HOME/Library/Mail Downloads/"
# make Library visible
chflags nohidden "$HOME/Library"
# clean up my Desktop
mkdir "$HOME/Documents/Temporary Files"
mv "$HOME/Desktop"/* "$HOME/Documents/Temporary Files"
# repair permissions
# run diskutil list to get the name of your partitions
diskutil repairPermissions `df -H | grep "/dev/disk" | head -1 | cut -c 1-10`
# clear out caches
rm -r "$HOME/Library/Caches"/*
sudo rm -r /Library/Caches/*
# Safari caches
rm -R "$HOME/Library/Caches/com.apple.Safari/Webpage\ Previews"
rm "$HOME/Library/Caches/com.apple.Safari/Cache.db"
# Chrome caches
rm "$HOME/Library/Caches/Google/Chrome/Default/Cache"/*
# Sleep image
sudo rm /private/var/vm/sleepimage
# Rebuild Spotlight index
sudo mdutil -E /
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment