Fix cpd shell command for multiple frame session

When more than two frame is used, buffer in the most recently *created* (not *visited*) frame is used.