When I exclusively use my laptop screen I prefer to have the Dock on the left edge, but when I plug in my external monitor I'd like to move the Dock to it instead.
Since my external screen is to the right of the laptop, the Dock will only appear on it if configured to appear on the bottom or right edge of the screen. As long as it's set to the left edge it remains on the laptop screen.
How do I accomplish this automatically whenever the external screen is (dis-)connected?
The solution mentioned here has nasty side-effects like unminimizing all my windows after killing the Dock:
defaults write com.apple.Dock orientation -string bottom