Refactor xd.tool.shell chdir/pushd/popd into xd.tool.os.pushd

Refactor the chdir, pushd, and popd functions into a new pushd context
manager, reducing code size of both implementation and use, while making
the resultant code more foolproof.

Signed-off-by: Esben Haabendal <esben@haabendal.dk>