work in progress

factored out pinentry and terminal to... someplace else...