Getting history out of ammonite

297 Views Asked by At

What is the best way to print history of code executed in ammonite repl in previous sessions? I am aware of repl.history but it contains code from current session and I know that ammonite keeps history of previous sessions because snippets from them are available using "up arrow" key.

1

There are 1 best solutions below

1
On BEST ANSWER

On Linux or Mac history is stored in your home directory in file ~/.ammonite/history, so you could maybe just load it from file:

import scala.util.Using
import scala.io.Source

val history = Using(Source.fromFile("/path/to/home/.ammonite/history"))(_.getLines)