I found this article but it handles the GUI solution.

I would like to automate the setup of a new machine, and do that I've created Dropbox shares of a number of my common configurations. (I could use a github repo, too) Other sites have discussed automating pref configs.

I'd like a bash / terminal command to create an alias in the dock. I presume that the dock is a folder of aliases located somewhere in ~/Library but I can't find it.

Is there any AppleScript solution?

edit: it seems that there is a file, ~/Library/Preferences/com.apple.dock.plist that contains the references.

A Japanese engineer discusses an way to do this C. 2009 (which no longer works).
Another script was designed to add folders to the 'others' area of the Dock – which is alos dated. The latter, however, along with the new format for the Dock plist, and some dict manipulation tips, gives more clues to creating a modern script.

  • Is it an application alias you are trying to create or an alias to a file? Once you give me more info I will be able to refine my answer for you.
    – Deesbek
    Commented Oct 14, 2013 at 20:52
  • 1
    I want to add an alias to a folder. Counts as a file? Commented Oct 14, 2013 at 21:12
  • Oki, I've given you the first command down below to modify the array for the file. All you need to do is add the link you want manually. Then check what has been changed in the dock.plist. Add the change to your script, use the same format with PlistBuddy I specify below.
    – Deesbek
    Commented Oct 14, 2013 at 21:19

1 Answer 1


Definitely scriptable with terminal commands.

/usr/libexec/PlistBuddy -c "Print" ~/Library/Preferences/com.apple.dock.plist

Shows you the actual configuration for the dock.

Within the above file you need to modify the "persistent-others" array if you want to create a "file" alias.

This is done the following way:

/usr/libexec/PlistBuddy -c "add:persistent-others:0 dict" ~/Library/Preferences/com.apple.dock.plist

If you want an application alias you will need to modify the "persistent-apps" array.

Once you make the changes and you are testing you need to do:

killall dock

to refresh the dock.

  • I can't make changes of less than 6 characters, so: you need to type killall Dock with a capital D.
    – pyb
    Commented Aug 28, 2015 at 13:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .