Skip to content

Instantly share code, notes, and snippets.

@dwijnand
Last active October 6, 2017 07:25
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwijnand/91f599f7d68056fa9e33f32c5b5a12e4 to your computer and use it in GitHub Desktop.
Save dwijnand/91f599f7d68056fa9e33f32c5b5a12e4 to your computer and use it in GitHub Desktop.
Stick it in ~/.sbt/0.13/reload.sbt
def buildFiles(b: File) = ((b * "*.sbt") +++ ((b / "project") ** ("*.scala" | "*.sbt")) filter (_.isFile))
def genBuildFilesHashesAt(base: File) = buildFiles(base).get.map(f => f -> (Hash toHex Hash(f))).toMap
def genBuildFilesHashes(units: Map[URI, LoadedBuildUnit]) =
(units.values flatMap (_.defined) map (_._2.base) flatMap genBuildFilesHashesAt).toMap.##
val buildFilesHashes = settingKey[Int]("") in Global
buildFilesHashes := genBuildFilesHashes(loadedBuild.value.units)
shellPrompt in Global := (s =>
"%s> ".format(
if (genBuildFilesHashes(Project structure s units) == buildFilesHashes.value) ""
else scala.Console.RED + "RELOAD " + scala.Console.RESET
))
@swsnr
Copy link

swsnr commented Oct 6, 2017

Do you have a SBT-1.0 version of this available?

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