Copy helper methods from irbrc to pryrc