[shell] rewrite: complete rewrite, now can be attached to any connection