25
votes

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,

3

3 Answers

33
votes

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.

5
votes

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

0
votes

I used ctrl + arrow up for previous input