From 10af1d66c0d8a3cef54a434e518f9ff8be72e0e6 Mon Sep 17 00:00:00 2001 From: Gunther Wittig Date: Wed, 27 Nov 2019 10:56:07 +0100 Subject: [PATCH 1/2] Make prompt more colourful --- src/main/scala/com/typesafe/sbt/SbtGit.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/typesafe/sbt/SbtGit.scala b/src/main/scala/com/typesafe/sbt/SbtGit.scala index c607388..c8bfa69 100644 --- a/src/main/scala/com/typesafe/sbt/SbtGit.scala +++ b/src/main/scala/com/typesafe/sbt/SbtGit.scala @@ -98,11 +98,12 @@ object SbtGit { val reader = extracted get GitKeys.gitReader val dir = extracted get baseDirectory val name = extracted get Keys.name + val end = scala.Console.BLUE + "> " + scala.Console.RESET if (isGitRepo(dir)) { - val branch = reader.withGit(_.branch) - name + "(" + branch + ")> " + val branch = scala.Console.GREEN + "[" + reader.withGit(_.branch) + "]" + scala.Console.RESET + name + branch + end } else { - name + "> " + name + end } } } From 4d257d4f72cee76428fbc85883f0bf8d6511d7fd Mon Sep 17 00:00:00 2001 From: Gunther Wittig Date: Wed, 4 Dec 2019 13:43:08 +0100 Subject: [PATCH 2/2] formatting --- src/main/scala/com/typesafe/sbt/SbtGit.scala | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/scala/com/typesafe/sbt/SbtGit.scala b/src/main/scala/com/typesafe/sbt/SbtGit.scala index c8bfa69..669c24e 100644 --- a/src/main/scala/com/typesafe/sbt/SbtGit.scala +++ b/src/main/scala/com/typesafe/sbt/SbtGit.scala @@ -3,6 +3,7 @@ package com.typesafe.sbt import sbt._ import Keys._ import git.{ConsoleGitRunner, DefaultReadableGit, GitRunner, JGitRunner, ReadableGit} +import scala.Console import sys.process.Process /** This plugin has all the basic 'git' functionality for other plugins. */ @@ -95,13 +96,14 @@ object SbtGit { val prompt: State => String = { state => val extracted = Project.extract(state) - val reader = extracted get GitKeys.gitReader - val dir = extracted get baseDirectory - val name = extracted get Keys.name - val end = scala.Console.BLUE + "> " + scala.Console.RESET + val dir = extracted.get(baseDirectory) + val name = extracted.get(Keys.name) + val end = s"${Console.BLUE}> ${Console.RESET}" if (isGitRepo(dir)) { - val branch = scala.Console.GREEN + "[" + reader.withGit(_.branch) + "]" + scala.Console.RESET - name + branch + end + val reader = extracted.get(GitKeys.gitReader) + val branchName = reader.withGit(_.branch) + val branchColored = s"${Console.GREEN}[$branchName]${Console.RESET}" + name + branchColored + end } else { name + end }