Skip to content

Instantly share code, notes, and snippets.

@radeksimko
Last active February 25, 2022 10:28
Show Gist options
  • Save radeksimko/9260956 to your computer and use it in GitHub Desktop.
Save radeksimko/9260956 to your computer and use it in GitHub Desktop.
Remove icons from OSX Dock
idsToRemove=(
"com.apple.Notes"
)
plistBuddy='/usr/libexec/PlistBuddy'
dockPlistPath="$HOME/Library/Preferences/com.apple.dock.plist"
for appIDToRemove in $idsToRemove; do
iconsIndexes=`defaults read com.apple.dock persistent-apps | grep tile-type | awk '/file-tile/ {print NR}'`
for i in $iconsIndexes; do
plistPath="persistent-apps:$[$i-1]"
appID=`$plistBuddy -c "Print $plistPath:tile-data:bundle-identifier" $dockPlistPath`
if [[ $appID =~ $appIDToRemove ]]; then
echo $appIDToRemove" is to be removed!"
$plistBuddy -c "Delete $plistPath" $dockPlistPath
iconsIndexes=iconsIndexes-1
break
fi
done
done
killall Dock
rm -rf /private/var/folders/*/*/-Caches-/com.apple.dock.iconcache
killall Dock
@Rickorn622
Copy link

hi @radeksimko thank you so much for providing such piece of code. This has helped me greatly in managing several user devices and "dock-items". Apple doesnt make it easy, does it.. Appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment