1

在以前的会话中打印在 ammonite repl 中执行的代码历史记录的最佳方法是什么?我知道,repl.history但它包含来自当前会话的代码,并且我知道 ammonite 保留以前会话的历史记录,因为它们的片段可以使用“向上箭头”键获得。

4

1 回答 1

3

在 Linux 或 Mac 上,历史记录存储在您的主目录中的 file 中~/.ammonite/history,因此您可以只从文件中加载它:

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

val history = Using(Source.fromFile("/path/to/home/.ammonite/history"))(_.getLines)
于 2019-12-30T21:56:53.497 回答