Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically clearing the screen on recompile in sbt

Tags:

sbt

I am using sbt with the sbt-revolver plugin and I want to clear the terminal screen (^L) when the project is recompiled (~ re-start). How can this be done?

like image 480
kyrre Avatar asked Jul 03 '14 10:07

kyrre


1 Answers

You could define new command clear, which would use jline to clear the screen. Sbt is using jline internally so you shouldn't have to include any extra dependency.

build.sbt

def clearConsoleCommand = Command.command("clear") { state =>
  val cr = new jline.console.ConsoleReader()
  cr.clearScreen
  state
}

val root = project.in(file(".")).settings(commands += clearConsoleCommand)

Now you could run your compile like this ~;clear;compile. This will trigger clear the console followed by compile on each file change (assuming this is what you want).

like image 59
lpiepiora Avatar answered Sep 26 '22 02:09

lpiepiora