Skip to content

Instantly share code, notes, and snippets.

@andrewpetrochenkov
Last active July 19, 2021 07:44
Show Gist options
  • Save andrewpetrochenkov/85ebeb63319ba2bdd8464104659a86b6 to your computer and use it in GitHub Desktop.
Save andrewpetrochenkov/85ebeb63319ba2bdd8464104659a86b6 to your computer and use it in GitHub Desktop.
macOS cleanup
#!/usr/bin/env bash
set -- "$@" $(/Library/Desktop\ Pictures -name "*.jpg")
set -- "$@" /Library/Desktop\ Pictures
set -- "$@" /Library/Documentation
set -- "$@" /Library/Logs
set -- "$@" /Library/Modem\ Scripts
set -- "$@" /Library/Screen\ Savers/Default\ Collections
set -- "$@" /Library/WebServer
set -- "$@" /Library/User\ Pictures
set -- "$@" /System/Library/Compositions # animations
set -- "$@" /System/Library/ScreenReader # Braille
# /System/Library/Speech/Voices/<name>.SpeechVoice
set -- "$@" $(
folders="$(find /System/Library/Speech/Voices -type d -mindepth 1 -maxdepth 1)"
[[ -n "$folders" ]] && while IFS= read path; do
/usr/libexec/PlistBuddy -c "Print :VoiceAttributes:VoiceLocaleIdentifier" "$path"/Contents/Info.plist 2> /dev/null | grep -q "$languages" || echo "$path"
done <<< "$folders"
)
# /System/Library/LinguisticData/<code>/, /System/Library/LinguisticData/RequiredAssets_<code>.bundle/
set -- "$@" $(
set -- ! -name "_*" ! -name "*en*"
[[ -n "$languages" ]] && while IFS= read lang; do
set -- "$@" ! -name "*$lang*"
done <<< "$languages"
find /System/Library/LinguisticData -type d "$@" -mindepth 1 -maxdepth 1
)
while [[ $# != 0 ]]; do
[[ -n "$1" ]] && [ -e "$1" ] && sudo rm -fr "$1"
shift
done;:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment