On Linux or OS X you should use rlwrap. It is included in most Linux package repositories. On OS X I installed rlwrap via MacPorts, which requires Xcode to be installed.
On Windows the q console comes with this functionality and you don't need to install anything.