Skip to content

Instantly share code, notes, and snippets.

@dcsobral
Created May 28, 2011 01:04
Show Gist options
  • Save dcsobral/996474 to your computer and use it in GitHub Desktop.
Save dcsobral/996474 to your computer and use it in GitHub Desktop.
SBT prompt with project name and current git branch
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 "-"
)
})
@etorreborre
Copy link

Thanks Daniel for sharing. I just had to change the regex in order to allow branch names to contain -:


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment