Skip to content

Commit

Permalink
SPARK-1349: spark-shell gets its own command history separate from sc…
Browse files Browse the repository at this point in the history
…ala repl

This fix is simply a modification of the default FileBackedHistory file setting:
https://github.com/scala/scala/blob/master/src/repl/scala/tools/nsc/interpreter/session/FileBackedHistory.scala#L77
  • Loading branch information
aarondav committed Mar 28, 2014
1 parent 21109fb commit f9c62d2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion repl/src/main/scala/org/apache/spark/repl/SparkJLineReader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

package org.apache.spark.repl

import scala.reflect.io.{Path, File}
import scala.tools.nsc._
import scala.tools.nsc.interpreter._
import scala.tools.nsc.interpreter.session.JLineHistory.JLineFileHistory

import scala.tools.jline.console.ConsoleReader
import scala.tools.jline.console.completer._
Expand All @@ -25,7 +27,7 @@ class SparkJLineReader(_completion: => Completion) extends InteractiveReader {
val consoleReader = new JLineConsoleReader()

lazy val completion = _completion
lazy val history: JLineHistory = JLineHistory()
lazy val history: JLineHistory = new SparkJLineHistory

private def term = consoleReader.getTerminal()
def reset() = term.reset()
Expand Down Expand Up @@ -78,3 +80,11 @@ class SparkJLineReader(_completion: => Completion) extends InteractiveReader {
def readOneLine(prompt: String) = consoleReader readLine prompt
def readOneKey(prompt: String) = consoleReader readOneKey prompt
}

/** Changes the default history file to not collide with the scala repl's. */
class SparkJLineHistory extends JLineFileHistory {
import Properties.userHome

def defaultFileName = ".spark_history"
override protected lazy val historyFile = File(Path(userHome) / defaultFileName)
}

0 comments on commit f9c62d2

Please sign in to comment.