Skip to content

Commit 7ce52c4

Browse files
aarondavpwendell
authored andcommitted
SPARK-1349: spark-shell gets its own command history
Currently, spark-shell shares its command history with scala 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 Author: Aaron Davidson <aaron@databricks.com> Closes #267 from aarondav/repl and squashes the following commits: f9c62d2 [Aaron Davidson] SPARK-1349: spark-shell gets its own command history separate from scala repl
1 parent 856c50f commit 7ce52c4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

repl/src/main/scala/org/apache/spark/repl/SparkJLineReader.scala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
package org.apache.spark.repl
99

10+
import scala.reflect.io.{Path, File}
1011
import scala.tools.nsc._
1112
import scala.tools.nsc.interpreter._
13+
import scala.tools.nsc.interpreter.session.JLineHistory.JLineFileHistory
1214

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

2729
lazy val completion = _completion
28-
lazy val history: JLineHistory = JLineHistory()
30+
lazy val history: JLineHistory = new SparkJLineHistory
2931

3032
private def term = consoleReader.getTerminal()
3133
def reset() = term.reset()
@@ -78,3 +80,11 @@ class SparkJLineReader(_completion: => Completion) extends InteractiveReader {
7880
def readOneLine(prompt: String) = consoleReader readLine prompt
7981
def readOneKey(prompt: String) = consoleReader readOneKey prompt
8082
}
83+
84+
/** Changes the default history file to not collide with the scala repl's. */
85+
class SparkJLineHistory extends JLineFileHistory {
86+
import Properties.userHome
87+
88+
def defaultFileName = ".spark_history"
89+
override protected lazy val historyFile = File(Path(userHome) / defaultFileName)
90+
}

0 commit comments

Comments
 (0)