I use Ammonite and ipython like REPL for Scala.
I find it handy to save history to file, so here is how to do it in Ammonite.
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.