Search code examples
ocamlpromptutop

Test if running in utop


I have added a few lines to my .ocamlinit to make the utop prompt less of an eyesore:

#require "react";;
#require "lambda-term";;
UTop.prompt := fst (React.S.create LTerm_text.(eval [
    S "\n";
    B_bold true;
    B_fg (LTerm_style.cyan);
    S "# ";
]));;

(I don't understand everything that is going on there... I just found it posted online and tweaked it.)

But now if I use the regular ocaml toplevel I get:

Error: Unbound module UTop

Can I add a test to .ocamlinit to skip those lines unless I'm running utop? Can I put them in an additional file that is only loaded by utop?


Solution

  • What if you add #require "utop";; ?