Ammonite Scala Shell
Ammonite Shell
The Ammonite Shell is a Scala-based shell with built-in libraries and short-cuts to provide the ability to do fully typed shell programming in Scala.
val l = (0 to 1000)
show(l, height=50)
# Multi-line edit:
def foo = {
val a = 10
val b = 15
val c = 30
}
# history shows multi-line (can use up arrow)
# History search:
enter search term, hit Up/down arrow
Also: Ctrl-r, start search, Ctrl-Shift-r cycle through search results
# Import 3rd party library
import $ivy.`com.example::scala:1.2.3`
Examples
Update sbt version for all projects under current directory
# Start Ammonite with 10GB of memory
JAVA_OPTS="-Xmx10g" amm
val allFiles = ls.rec(wd)
val sbtVersionFiles = allFiles.filter{ f =>
val segmentCount = f.segmentCount
if (segmentsCount >= 2) {
val parentDir = f.getSegment(segmentCount - 2)
val lastSegment = f.last
parentDir == "project" && lastSegment == "build.properties"
} else {
false
}
}
sbtVersionFiles.foreach { versionFile =>
//also: write (fail if file exists)
//write.append
write.over(versionFile, "sbt.version=1.2.8\n")
}