In an OCaml custom toplevel, is there a way to programatically set the prompt from # to something else? I would like to be able to change it in response to the user’s last one of my custom functions (kinda like in bash how you can set PS1). I can’t even find a #directive to change it. Thanks!
In an OCaml custom toplevel, is there a way to programatically set the prompt
Share
In toplevel/toploop.ml:
But wait! The computed prompt is passed to
!read_interactive_input,and this reference is exported:
In toplevel/toploop.mli:
So it would seem that all you have to do is change the value of
Toploop.read_interactive_inputfrom its default to a function that ignores the passed prompt and prints the one you want instead.The default value for
read_interactive_inputis:So you can use: