25

Everytime I use these keys in the interpreter I keep getting symbols like this appearing:

[[D^[[C

I'm using Linux Mint 12 in ZSH, however I'm getting the same result in Ubuntu with bash. Also, same thing in ssh.

jrouquie
  • 4,315
  • 4
  • 27
  • 43
Pacane
  • 20,273
  • 18
  • 60
  • 97

2 Answers2

26

The stock OCaml toplevel doesn't have line editing built in. I use rlwrap:

$ cat bin/ocaml
#!/bin/sh
exec rlwrap /usr/local/bin/ocaml "$@"

Using the toplevel without something like this is quite painful, in my opinion!

Other possibilities are to run the toplevel under emacs (a popular choice, I think), or to use utop. I haven't used utop, but it sounds cool.

Jeffrey Scofield
  • 65,646
  • 2
  • 72
  • 108
  • 2
    utop is very cool. In addition to supporting basic line editing (arrow keys to move the cursor around, history) utop also supports fairly robust context-sensitive completion. For example, L.i will complete to List.iter (assuming the stdlib is the only thing in scope). – hcarty Nov 05 '12 at 14:03
  • Wow Indeed utop is very cool. It needed some packages to install but wow! Thanks a lot! – Pacane Nov 05 '12 at 23:23
20

Another option is to use: ledit ocaml

Although I prefer utop over anything else myself.

rgrinberg
  • 9,638
  • 7
  • 27
  • 44