简体   繁体   中英

Print history list with ocaml utop

Is there a way to print the history list in utop, like calling history from bash? I haven't found any sort of history ring associated with utop-mode in emacs either. I'm trying to use the history to hippie-expand against in the REPL.

Utop appears to respond to commands like history-prev and history-next (from utop.el ), but that is all I have found.

This

μ> #require "lambda-term";;
μ> LTerm_history.contents UTop.history;;

will print out your utop history as an OCaml list of strings with the first element being the latest command you've executed (which is unsurprisingly "LTerm_history.contents UTop.history;;" ).

Note: you can add #require "lambda-term";; into your .ocamlinit file to skip the first command in the above listing.

There is also ~/.utop-history file, if you'd like to use some system utilities to access your utop history.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM