Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to repeat last command in OCaml interpreter shell

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,

like image 504
neildaemond Avatar asked Aug 01 '12 10:08

neildaemond


People also ask

How do you repeat the last command in Python shell?

Answer #3:Alt + p for previous command from histroy, Alt + n for next command from history. This is default configure, and you can change these key shortcut at your preference from Options -> Configure IDLE.

How do I recall a previous command in Python?

Adapt yourself to IDLE: Insted of hitting the up arrow to bring back a previous command, if you just put your cursor on the previous command you want to repeat and then press "enter", that command will be repeated at the current command prompt. Press enter again, and the command gets executed.

Which is used to recall the previously executed commands in Python shell?

Recalling Python code Lines of code executed in previous lines can be recalled using the up and down arrow keys. This recall inserts the specified line at the current command prompt location.


2 Answers

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.

like image 179
Igor Chubin Avatar answered Oct 13 '22 05:10

Igor Chubin


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

like image 5
Pierre Chambart Avatar answered Oct 13 '22 06:10

Pierre Chambart