Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

History in Clojure REPL

I'm doing my first steps with Clojure, but for some reason the up/down keys don't allow me to step through the command history in the REPL like in REPLs of other languages. Does the Clojure REPL use different keys to access the command history, or is this feature just not (yet) implemented?

like image 216
dhofstet Avatar asked Nov 02 '11 14:11

dhofstet


5 Answers

If you are, by any chance, using a Unix-like environment you can use rlwrap to to achieve nice things like command line history and Ctrl-R for searching through it.

Just prepend your command which you use to start repl, e.g:

rlwrap java -cp clojure.jar clojure.main

like image 162
Goran Jovic Avatar answered Nov 14 '22 09:11

Goran Jovic


Or use Leiningen or Cake. Either of these are useful in general, and you'll be happy to learn to use them, but specifically they use readline or jline automatically where available.

like image 22
amalloy Avatar answered Nov 14 '22 07:11

amalloy


You can enhance the REPL to do this by using JLine, see here.

like image 31
Jeff Foster Avatar answered Nov 14 '22 09:11

Jeff Foster


Depends which REPL you use. Most good REPLs have this functionality and more.

If you're coming from Java as an Eclipse user, for example, you may want to use the embedded nREPL provided by the Counterclockwise plugin. I found this easier to use than configuring a separate dedicated Clojure environment.

like image 42
mikera Avatar answered Nov 14 '22 09:11

mikera


C-, M-x slime-repl-forward-input C-, M-x slime-repl-backward-input Go to the next/previous history item.

http://common-lisp.net/project/slime/doc/html/Input-Navigation.html

like image 1
user811766 Avatar answered Nov 14 '22 08:11

user811766