CD plugin: change work directory on tab switch.

The current working directory is saved when leaving a tab and restored
when reentering that same tab.

This does have the small side effect that tabs tend to switch places
because their tab name shrinks/expands when switching current directory.