Last active
October 24, 2018 16:11
-
-
Save ssanj/0ecd4a9670f204e9b5c2e5dce31f3d0f to your computer and use it in GitHub Desktop.
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
//put in ~/.sbt/1.0/global.sbt if you want this to be the default shell everywhere | |
import scala.sys.process._ | |
import scala.util.Try | |
shellPrompt := { s: State => | |
val extracted = Project.extract(s) | |
val devNull = ProcessLogger(_ => ()) | |
val branchOp: Option[String] = Try(sys.process.Process("git rev-parse --abbrev-ref HEAD").!!(devNull)). | |
map(_.replace("\n", "").replace("\r", "")). | |
toOption | |
(name in extracted.currentRef).get(extracted.structure.data) match { | |
case Some(name) => | |
branchOp.fold(s"${RESET}${CYAN}${name}${RESET}> ")(branch => | |
s"${RESET}${CYAN}${name}${RESET}:${RESET}${YELLOW}${BOLD}${branch}${RESET}> ") | |
case _ => "> " | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment