Clojure : 'lein repl' history grepping?
Asked Answered
T

4

7

I often find myself executing commands like this at bash :

history | grep 'find'

For example to look up a fancy find / xargs command i might have ran.

Im wondering --- where does the "lein repl" store its historical data ? It would be nice to know, because then I could write a leingrep.sh script, which simply grepped through the lein history session.

It is obvious that this is on disk somewhere, since history is preserved from one repl to the next.

Twotone answered 1/4, 2012 at 15:25 Comment(0)
T
9

Lein is using either readline (if you have it installed) or jline (if you are so unfortunate, I recommend installing readline). I wouldn't bother trying to look up the history file on disk - just press Ctrl-r, type in your search text, and keep hitting Ctrl-r until you find whatever you were looking for. This is a general readline feature, and will work in any readline app (including bash).

Touraine answered 1/4, 2012 at 20:59 Comment(0)
G
4

Once you get going with readline there are a couple controls to consider, via your ~/.inputrc file.

I'm not finding the default "history size" documented, but I'm guessing it's only ~100. I often lose some older entries I wished I'd had around. Also, "vi-mode" is wonderful thing for vi users. Together these (with a bonus) in .inputrc become:

set history-size 10000
set editing-mode vi
# Only require 1 tab for completion.
set show-all-if-ambiguous on

Note that this config will affect a lot of repl tools, like gdb, irb/pry, lein, psql, ipython, R, ...

Garrity answered 29/5, 2012 at 4:52 Comment(0)
C
0

Looking at my home folder. Seems like the lein repl has chosen jline. The files where the history is stored is as follows: ~/.jline-clojure.main.history ~/.jline-reply.history

Hope this helps.

Canales answered 3/2, 2013 at 6:17 Comment(0)
O
0

I installed lein through Homebrew on my Mac:

brew install leiningen

and the history file is stored in my home directory:

~/.lein/repl-history

Version is:

% lein --version
Leiningen 2.6.1 on Java 1.8.0_77 Java HotSpot(TM) 64-Bit Server VM

(I don't have no ~/.inputrc nor ~/.jline*)

Oxyhydrogen answered 5/11, 2016 at 17:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.