Created
May 28, 2011 01:04
-
-
Save dcsobral/996474 to your computer and use it in GitHub Desktop.
SBT prompt with project name and current git branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shellPrompt <<= name(name => { state: State => | |
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) | |
"%s:%s>" format ( | |
name, | |
current findFirstMatchIn gitBranches map (_.group(1)) getOrElse "-" | |
) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks Daniel for sharing. I just had to change the regex in order to allow branch names to contain
-
: