nushell/docs/commands/with-env.md
JT bff81f24aa
Autogenerate missing docs (#3514)
* Autogenerate missing docs

* Update ansi.md

* Rename question mark command docs

* Delete empty?.md
2021-05-30 12:57:04 +12:00

754 B

with-env

Runs a block with an environment variable set.

Usage

> with-env <variable> <block> {flags} 

Parameters

  • <variable> the environment variable to temporarily set
  • <block> the block to run once the variable is set

Flags

  • -h, --help: Display this help message

Examples

Set the MYENV environment variable

> with-env [MYENV "my env value"] { echo $nu.env.MYENV }

Set by primitive value list

> with-env [X Y W Z] { echo $nu.env.X $nu.env.W }

Set by single row table

> with-env [[X W]; [Y Z]] { echo $nu.env.X $nu.env.W }

Set by row(e.g. open x.json or from json)

> echo '{"X":"Y","W":"Z"}'|from json|with-env $it { echo $nu.env.X $nu.env.W }