Skip to content

Using Readline with REPLs for Better Editing

nchurch edited this page May 27, 2012 · 11 revisions

By default, the REPLs provided by the lein-cljsbuild REPL commands only have very basic command-line editing support, and are rather painful to use. If you have rlwrap installed, though, you can enable rich command-line editing by running something like this (note that these examples were written using rlwrap version 0.37):

rlwrap -r -m -q '\\"' -b "(){}[],^%3@\\";:'" lein trampoline cljsbuild <repl-command>

(Note that on Mac OS, you may have to omit the -q). To avoid the tediousness of pasting the above command each time you wish to start a REPL, you might want to add a simple wrapper script to your $PATH. I put this script in ~/bin/cljs-repl. Don't forget to make it executable!

#!/bin/bash
rlwrap -r -m -q '\\"' -b "(){}[],^%3@\\";:'" lein trampoline cljsbuild repl-$1

Now you can run cljs-repl rhino, cljs-repl listen, etc, and have full readline support.