split terminal io code out