Sub topic 18
Changing Dock Settings from Terminal
This chapter assumes you can open Terminal, you know the Dock settings in System Settings, and you are comfortable pasting short commands. The defaults command reads and writes the same preference files that System Settings edits, so everything here can also be done with the mouse.
Changing Dock settings from Terminal
Each app stores its preferences in a domain. The Dock's domain is com.apple.dock. A key is one named setting inside a domain, such as autohide. The defaults command has three verbs you need: read, write, and delete.
Start by reading a value:
defaults read com.apple.dock autohideIt prints 1 when the Dock hides automatically. If the key has never been set, it prints an error. That error is normal and means the Dock is using its default.
Writing needs a type flag so the value is stored correctly. This example turns on auto-hiding and sets the icon size to 48 points:
defaults write com.apple.dock autohide -bool true
defaults write com.apple.dock tilesize -int 48
killall DockThe Dock reads its preferences when it starts. killall Dock quits the Dock process, and macOS relaunches it at once with your new values. Without that line, nothing visible changes.
Here are two more changes you can make the same way. The first hides the section of recently used apps at the right end of the Dock:
defaults write com.apple.dock show-recents -bool false
killall DockThe second moves the Dock to the left edge. The other valid values are bottom and right:
defaults write com.apple.dock orientation -string left
killall DockTroubleshooting and resetting
Most problems come from a few causes.
| Symptom | Likely cause | Fix |
|---|---|---|
| Nothing changed | You skipped `killall Dock` | Run `killall Dock` |
| `defaults read` prints an error | The key was never set | Expected. The default applies |
| Dock icons are huge or tiny | An old `tilesize` value | Delete the key or set a new `-int` value |
| Dock is missing | `autohide` is on | Move the pointer to the screen edge, or reset |
| Dock is on the wrong edge | `orientation` was set | Write `bottom`, or delete the key |
A "missing" Dock is often just hidden. Point at the edge where the Dock should be and wait a moment. A hidden Dock also reappears with Option-Command-D.
To undo every change from this chapter, delete the keys. Deleting a key removes your override, so the Dock falls back to its default for that setting.
defaults delete com.apple.dock autohide
defaults delete com.apple.dock tilesize
defaults delete com.apple.dock show-recents
defaults delete com.apple.dock orientation
killall DockIf a delete command reports that the key does not exist, you have not set it, so there is nothing to undo. Carry on with the next line.
Exercise
You run defaults write com.apple.dock orientation -string right and the Dock does not move. What did you forget, and how would you later return the Dock to its default position?
Show answer
You forgot to run killall Dock, so the Dock never reloaded its preferences. To restore the default, run defaults delete com.apple.dock orientation followed by killall Dock.