
Untitled
By: a guest on
May 5th, 2012 | syntax:
None | size: 0.86 KB | hits: 13 | expires: Never
import sbt._
import Keys._
// source of the actual shell modification take from Daniel C. Sobral's gist:
// https://gist.github.com/996474
// prompt looks like:
// $PROJECTNAME:$GITBRANCH>
object ShellPrompt extends Plugin {
object devnull extends ProcessLogger {
def info(s: => String) {}
def error(s: => String) { }
def buffer[T](f: => T): T = f
}
val current = """\*\s+(\w+)""".r
def gitBranches = ("git branch --no-color" lines_! devnull mkString)
def prompt(name: String) =
"%s:%s> " format (name,
current findFirstMatchIn gitBranches map (_.group(1)) getOrElse "-"
)
override def settings: Seq[Setting[_]] =
if (System.getProperty("sbt.nologformat", "false") != "true")
Seq[Setting[_]](
shellPrompt <<= name(name => { state: State => prompt(name) })
)
else
Seq()
}
// vim: set ts=4 sw=4 et: