Is there any special support for environment variable access in Ammonite?

655 views Asked by At

I'm wondering if ammonite has a convenient, shorthand way to access environment variables from the parent process, or is scala.util.Properties.envOrElse the suggested method? (How to read environment variables in Scala)

Related: is there a way to list all current objects in ammonite? Somewhat analogous to env in bash, though possibly different, as it seems that environment variables are not imported as vals or vars.

1

There are 1 answers

0
Jacob Wang On BEST ANSWER

There is sys.env (Scala default import - available in Scala REPL too). You can use the show function in ammonite to avoid truncation in printed output.

Example:

show(sys.env)

sys.env("HOME")