Make utop less visually noisy?

utop seems to come out the box with a lot of colorful terminal bling, which isn’t really to my taste - can I strip it down to just a prompt? man utoprc suggests I can control specific colors, but not whether elements are actually displayed…

I had the same feeling when I started. You can fix the problem by putting this in your .ocamilinit:

#utop_prompt_dummy;;
UTop.set_show_box false

Later, I decided that I sometimes like to be able to turn on the list of available names for completion of what one is typing, so I added this:

let ubox () =
  if UTop.get_show_box()
  then UTop.set_show_box false
  else UTop.set_show_box true
;;

Then entering ubox();; toggles the extra information on and off.

2 Likes

This is a really useful tip for easy cut-and-paste as well, without the box getting in the way! Contributing it to the manual page or README of utop would be fantastic.

I can do that. Just need to find a moment. There may be a place for it on ocamlverse, too.

This is what I have in my ~/.ocamlinit for a relatively minimal utop setup. Less noisy, and with visible completion at the same time:

  #require "lambda-term";;
  let prompt = LTerm_text.(eval [B_fg (LTerm_style.green); S "# "]);;
  UTop.prompt := fst (React.S.create prompt);;

This is how it looks:

─────────────┬─────────────────────────────────────────────────────────────┬──────────────
             │ Welcome to utop version 2.3.0 (using OCaml version 4.07.0)! │              
             └─────────────────────────────────────────────────────────────┘              

Type #utop_help for help about using utop.

# 1 + 1;;
- : int = 2
# "hello utop";;
- : string = "hello utop"
# 
┌───┬─────┬───────────┬──────────────┬────────┬──────┬─────┬───────────┬────────┬────────┐
│Arg│Array│ArrayLabels│Assert_failure│Bigarray│Buffer│Bytes│BytesLabels│Callback│Camlinte│
└───┴─────┴───────────┴──────────────┴────────┴──────┴─────┴───────────┴────────┴────────┘

3 Likes