Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Do any of these IRB alternatives support multi-line history? I want to define a function, press up and have the whole function definition there instead of the last line of it -- how it works with Clojure's REPL.


I just implemented it for ripl, http://github.com/cldwalker/ripl, in two ways: https://gist.github.com/939846. First way would put it in your history as a one-liner. The second would let you edit the last code block in your editor. The gist shows an example.

If you want to try this out, simply `gem install ripl ripl-multi_line` and add the gist to ~/.riplrc. Since this is a hack, I would open an issue on https://github.com/janlelis/ripl-multi_line/issues if you want it to be done properly.

If you were talking about using readline's multi-line history, I'm not sure if ruby's readline library has an api to it. Would be useful.


Hey, I've implemented it for the ripl multi_line plugin <https://github.com/janlelis/ripl-multi_line/>; (version 0.3.0).

You can change the behavior with the Ripl.config[:multi_line_history] option. Possible values: * :compact - transform the last statement into a ; separated one-liner * :block - just join the last multi-line statement to one block ("\n") * :blank - do nothing


Python's IDLE does this as well. It's hugely frustrating in other REPLs (irb, iPython) to type out a 5-line block only to find that you missed a keystroke on line 2. I'm hoping there's a keyboard shortcut I don't know about.


It does work in ipython it just is annoying to navigate and you have to rely on the automatic indenting a bit more if you are adding anything (as the ...: is missing).

Unless of course you mean history through different sessions as that doesn't work for full functions.


With IDLE a quick Ctrl-P will bring up the entire previous block input, including indents, all at once.


Indents are included with a simple up arrow with ipython, it also works if you are doing a backwards search (C-r), it just doesn't have the nice formatting you get when you first write the function.

Idle is a bit easier to edit the function though.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: