Skip to content

Instantly share code, notes, and snippets.

@dcordero
Created September 26, 2018 13:54
Show Gist options
  • Save dcordero/c4dce4508b9d5327fb82b0dbcca75102 to your computer and use it in GitHub Desktop.
Save dcordero/c4dce4508b9d5327fb82b0dbcca75102 to your computer and use it in GitHub Desktop.
#!/bin/sh
xcode_path=$1
# Backup icon
cp "${xcode_path}/Contents/Resources/Xcode.icns" "${xcode_path}/Contents/Resources/Xcode-original.icns"
# Get version
version=`${xcode_path}/Contents/Developer/usr/bin/xcodebuild -version | head -1 | cut -f2 -d' '`
# Unpack icon
iconutil -c iconset -o /tmp/badge.iconset "${xcode_path}/Contents/Resources/Xcode.icns"
# Badge
cd /tmp/badge.iconset
badge --shield "Xcode-${version}-blue" --no_badge --shield_gravity South --glob "/*.png"
# Pack icon
iconutil -c icns /tmp/badge.iconset -o ${xcode_path}/Contents/Resources/Xcode.icns
# Refresh icon
touch ${xcode_path}
rm /var/folders/*/*/*/com.apple.dock.iconcache
killall Finder Dock
# Clean tmp env
rm -rf /tmp/badge.iconset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment