Move Dock to another screen edge when unplugging monitor
Use ControlPlane to run the following shell script whenever the state of the monitor connection changes:

move dock to bottom.sh:

#!/bin/bash

osascript -e '
tell application id "com.apple.systemevents"
    tell dock preferences
        set screen edge to bottom
    end tell
end tell
'


Duplicate the file, where you replace bottom with left.

Set up ControlPlane


Create two ControlPlane contexts: Laptop screen only and External monitor.
Enable the 'Attached Monitor' evidence source.
Create two 'Attached Monitor' rules – one negated -- that switch to the corresponding context with 100% certainty when they fire.
Create two actions that run the two shell scripts On arrival to their corresponding contexts.