Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clojure : 'lein repl' history grepping?

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.

like image 808
jayunit100 Avatar asked Apr 01 '12 15:04

jayunit100


2 Answers

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).

like image 146
amalloy Avatar answered Sep 28 '22 07:09

amalloy


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, ...

like image 38
Micah Elliott Avatar answered Sep 28 '22 06:09

Micah Elliott