how to repeat last command in OCaml interpreter shell
Asked Answered
A

3

25

I've been trying out OCaml. Sometimes its quicker just to test out some code using the interpreter shell but, it doesn't bring up the last command when I press the 'up' key.

Its a pain when I miss type something or wish to see what a little variation would produce.

Anyone know if there is another key for it?

Thanks,

Assistance answered 1/8, 2012 at 10:24 Comment(0)
A
35

Use rlwrap:

rlwrap ocaml

ocaml itself has no readline support.

You can configure readline using ~/.inputrc. For example, you could add such lines to it:

$if ocaml
"\C-o": "()\C-b"
"\C-n": ";;\n"
$endif

Now you can use ctrl-o and ctrl-n hotkeys in ocaml. Just try it.

Archine answered 1/8, 2012 at 10:28 Comment(4)
There is also ledit, which works like rlwrap: ledit ocaml. Install with sudo apt-get install ledit if you're using Debian or Ubuntu.Apheliotropic
cool, ledit was already installed on my ubuntu machine. rlwrap was just as easliy installed with sudo apt-get install rlwrap too... is there any benefit in one over the other?Assistance
@neildaemond: I found rlwrap better. rlwrap gives you history, filename completion, prompt coloring, syntax completion, brackets matching, use of an external editor and easy configuration via .inputrc.Archine
Thanks for adding more to your answer, rlwrap it is~ I just added alias ocaml='rlwrap ocaml' into my .bashrc :)Assistance
F
5

You can use the improved toplevel utop. Moreover, it includes nice completion capacities.

Footwall answered 2/8, 2012 at 23:11 Comment(0)
K
0

I used ctrl + arrow up for previous input

Keslie answered 26/1, 2021 at 9:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.