Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Remove App from Dock

I know how add an app to the dock using unix but how do you remove one from the Dock? I have read a lot about using plistbuddy to remove it but I can not figure it out. I want to put this script in a installer/uninstaller.

Posted on Sep 29, 2011 8:19 AM

Reply
Question marked as Best reply

Posted on Sep 29, 2011 10:51 AM

Got it! You can use this script:



!/bin/bash


i="$(defaults read com.apple.dock persistent-apps | grep _CFURLString\" | awk '/What ever app you want/ {print NR}')"


for j in `echo "$i" | tr " " "\n" | sort -gr`


do

/usr/libexec/PlistBuddy -c "Delete persistent-apps:$[$j-1]" ~/Library/Preferences/com.apple.dock.plist

done


killall Dock



just save that as a executable file and you are good to go.

2 replies
Question marked as Best reply

Sep 29, 2011 10:51 AM in response to Mac Man Smith

Got it! You can use this script:



!/bin/bash


i="$(defaults read com.apple.dock persistent-apps | grep _CFURLString\" | awk '/What ever app you want/ {print NR}')"


for j in `echo "$i" | tr " " "\n" | sort -gr`


do

/usr/libexec/PlistBuddy -c "Delete persistent-apps:$[$j-1]" ~/Library/Preferences/com.apple.dock.plist

done


killall Dock



just save that as a executable file and you are good to go.

Sep 29, 2011 12:06 PM in response to Mac Man Smith

Forget the looping, do the math in bash ->

i=$(( $(defaults read com.apple.dock persistent-apps | grep _CFURLString\" | awk '/What ever app/ {print NR}') -1 ))
/usr/libexec/PlistBuddy -c "Delete persistent-apps:$i" ~/Library/Preferences/com.apple.dock.plist

Note the missing colon at the start of persistent-apps. <comment>I'm not liking this new forum software</comment>


Ok, I understand why you're looping. But it would be silly to have more than one of the same app in the dock.


Message was edited by: Mark Jalbert

Remove App from Dock

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.