Adding applications to dock through terminal

macos, terminal

Solution

I'm running Mavericks and this worked for me:

defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Google Chrome.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'

killall Dock

Problem

I'm managing multiple computers and want to send out a script that will run in terminal that will add certain applications to the dock. The code I am trying is ``` defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict> <key>file-data</key><dict><key>_CFURLString</key><string>/Macintosh HD/Applications/Google Chrome.app/</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' killall Dock; ``` I have also tried ``` defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Google Chrome.app/</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' killall Dock; ``` with and without spaces in between Google Chrome. Thanks for any help in advance.

Original source