Readline love for the Clojure REPL using rlwrap
One of the painful things about the REPL/shells of JVM based languages like Clojure and JRuby is that they have no support for Readline out of the box. No command history, navigation, nothing.
This can be solved in one of two way - the JLine java library, and rlwrap.
I favour rlwrap approach because this way, I can add readline support without having to mess with java classpaths or the clj script set up by Hombrew.
All you need to do is install rlwrap (brew install rlwrap / apt-get install rlwrap) then setup a simple shell script like so:
#!/bin/bash
rlwrap --quote-characters="'" --command clojure clj
Name it something like cljrl, make it executable and put on your path. This approach should work for JRuby too.
If you're wondering about the arguments to rlwrap, --quote-characters ensures that the single quote is not treated as a paired quote character and --comand ensures that history is maintained between sessions (-Djline.history='clojure' if you're using JLine IIRC).Thanks to Enrico Franchi for originally posting this - I went the JLine route first and he saved me a lot of yak shaving.