Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make prompt more colourful #174

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/main/scala/com/typesafe/sbt/SbtGit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -95,14 +96,16 @@ 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 dir = extracted.get(baseDirectory)
val name = extracted.get(Keys.name)
val end = s"${Console.BLUE}> ${Console.RESET}"
if (isGitRepo(dir)) {
val branch = reader.withGit(_.branch)
name + "(" + branch + ")> "
val reader = extracted.get(GitKeys.gitReader)
val branchName = reader.withGit(_.branch)
val branchColored = s"${Console.GREEN}[$branchName]${Console.RESET}"
name + branchColored + end
} else {
name + "> "
name + end
}
}
}
Expand Down