David Portabella David Portabella - 4 months ago 29x
Bash Question

run a Ammonite scala script without typing amm

I try to use Ammonite to write scripts written in Scala

Example from the website: Args.scala

val x = 1
import ammonite.ops._
def main(i: Int, s: String, path: Path = cwd) = {
println(s"Hello! ${s * i} ${path.relativeTo(cwd)}.")

to run it:

$ amm Args.scala 3 Moo

is it possible to write a script that can run by itself, instead of calling
amm Args.scala
, such as?

$ Args.scala 3 Moo

i tried adding the following to the head of Args.scala:


and making it executable with
chmod +x Args.scala
, but it does not work. it is as if bash (instead of amm) is running the script, and don't understand the first command
val x = 1


Try with this header #!/usr/bin/env amm.