Skip to content

Instantly share code, notes, and snippets.

@fehu
Created December 20, 2017 21:52
Show Gist options
  • Save fehu/ef41de0bde61fd9157e340f6f5a8a7e9 to your computer and use it in GitHub Desktop.
Save fehu/ef41de0bde61fd9157e340f6f5a8a7e9 to your computer and use it in GitHub Desktop.
ammonite predef
interp.load.ivy(
"com.lihaoyi" %
s"ammonite-shell_${scala.util.Properties.versionNumberString}" %
ammonite.Constants.version
)
@
val shellSession = ammonite.shell.ShellSession()
import shellSession._
import ammonite.ops._
import ammonite.shell._
ammonite.shell.Configure(interp, repl, wd)
implicit class PromtExt(promt: ammonite.repl.FullReplAPI) {
def promtShort(): Unit = repl.prompt() = "> "
def promtFull(): Unit = repl.prompt.bind(prefix + ":" + shortWd + "> ")
private def shortWd =
if (wd startsWith home) "~/" + wd.relativeTo(home).toString
else wd.toString
private lazy val prefix =
sys.props("user.name") + PromtExt.org.map("@" + _).getOrElse("")
}
object PromtExt {
protected val org = None
}
repl.promtFull()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment