Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dcsobral
Created May 28, 2011 01:04
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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