I find it handy to save history to file, so here is how to do it in Ammonite.
import java.io.BufferedWriter import java.io.FileWriter val file = new File("some-file.scala") val bw = new BufferedWriter(new FileWriter(file)) val history = repl.history.mkString("\n") bw.write(history) bw.close()
Ammonite exposes a global object called
repl, which has a method called
history. The code above converts history to a new line separated string and writes it to file.