Skip to content

Instantly share code, notes, and snippets.

@cfg
Created November 16, 2020 20:00
Show Gist options
  • Save cfg/77f941b4e86ba419c75f818101072be1 to your computer and use it in GitHub Desktop.
Save cfg/77f941b4e86ba419c75f818101072be1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Take a snapshot of user and system application icons before the Big Sur aesthetic is applied
function sync() {
FROM="$1"
TO="$2"
mkdir -p "$TO"
# Temporarily rename all foo_app to foo.app for sync purposes
find "$TO" -depth -name "*_app" -exec sh -c 'mv "$1" "${1%_app}.app"' _ {} \;
# To "lock" an icon provide the relative path to the containing folder
## e.g. "Google Chrome.app/Contents/Resources/*.icns"
# To lock all icons in an app use **
## e.g. "Google Chrome.app/**.icns"
# To only copy new files, add the rsync flag --ignore-existing
# To preview, add --dry-run
rsync -zarv --prune-empty-dirs \
--ignore-existing \
--exclude="Google Chrome Canary.app/Contents/Resources/*.icns" \
--exclude="Google Chrome.app/Contents/Resources/*.icns" \
--include "*/" \
--include="*.icns" \
--include="Info.plist" \
--exclude="*" \
"$FROM" "$TO"
# Rename all foo.app to foo_app to avoid confusing launchers that look for apps
find "$TO" -depth -name "*.app" -exec sh -c 'mv "$1" "${1%.app}_app"' _ {} \;
}
# Uncomment lines below to create a "synced_icons" folder in the current directory and sync specified folders
# sync "/Applications/" "./synced_icons/Applications"
# sync "$HOME/Applications/" "./synced_icons/UserApps"
# Includes System /Applications/Utilities as well
# sync "/System/Applications/" "./synced_icons/SysApps"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment