Skip to content

Instantly share code, notes, and snippets.

@michaeldfallen
Last active August 29, 2015 14:04
Show Gist options
  • Save michaeldfallen/712ff643c285a7d378be to your computer and use it in GitHub Desktop.
Save michaeldfallen/712ff643c285a7d378be to your computer and use it in GitHub Desktop.
Clear your shell in sbt
object ClearShell {
  lazy val clearShell = TaskKey[Unit](
    "clear",
    "Clears your shell. Useful to clear screen between test runs e.g. ~; clear ; test"
  )
  lazy val clearShellTask = clearShell := {
    """printf \033c""".!
  }
  val settings = Seq(
    clearShellTask
  )
}

Useful little util I add to any Build.scala. When doing test-first development having your terminal full of old test runs can be a real pain. This little task lets me use ~; clear ; test-only io.michaelallen.foo._ to clear the screen before each test run.

Explanation of the printf \033c part: Answer by Sandeep Datta to Stack Overflow question Clear the Ubuntu bash screen for real

To use it simply add it to your Build.scala then add .settings(ClearShell.settings:_*) to your project definition.

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