Bozhidar Batsov over at the excellent Emacs Redux has a very nice post on how to clear comint buffers. Comint is the machinery behind Eshell, and Shell mode. It is a general-purpose mode for communicating with interactive subprocesses and is thus behind many of the REPL systems such as Lisp and Ruby.
Oddly, comint has no way of clearing the buffer, something I’ve often wanted when working with Eshell. Bozhidar shows us how to do that with just a few lines of Elisp. If you use any of the comint-based mechanisms, you should take a look. It will make your life just a bit easier.