抓取scala REPL历史记录(来自sbt控制台)

mat*_*ter 8 scala

是否有可能获得在scala repl上输入的所有最新命令的历史列表?(sbt console如果重要的话,在里面运行repl ).:history然后返回显示作品的命令数量,但能够将其导出到可以处理为scala源文件的文本文件中会很好.

Gar*_*all 10

Scala 2.11+中,有新的REPL命令可以保存输出.请参见此处: 如何保存REPL会话?

在早期版本中,您可以在此处获取REPL历史记录: less ~/.scala_history


小智 10

这是一个简单的伎俩:

    scala> def history = scala.io.Source.fromFile(System.getProperty("user.home") + "/.scala_history").foreach(print)
    scala> history
Run Code Online (Sandbox Code Playgroud)