1

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.

Community
  • 1
  • 1
bbarker
  • 11,636
  • 9
  • 38
  • 62

1 Answers1

3

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")

Jacob Wang
  • 4,411
  • 5
  • 29
  • 43