O God, I could be bounded in a nutshell, and count myself a king of infinite space, were it not that I have bad dreams.
Attribution checked
Quothly found supporting evidence for this attribution.
The line appears in Act 2, Scene 2 of Shakespeare's Hamlet — "O God, I could be bounded in a nutshell, and count myself a king of infinite space, were it not that I have bad dreams."
Royal Shakespeare Company — Playmaking Pack: Hamlet