mirror of
https://github.com/nushell/nushell.git
synced 2025-08-14 05:58:40 +02:00
Auto-generate markdown command docs (#4451)
* Finish updating * a couple improvements * Update renames * cleanup examples
This commit is contained in:
@ -1,36 +1,39 @@
|
||||
# with-env
|
||||
---
|
||||
title: with-env
|
||||
layout: command
|
||||
version: 0.59.0
|
||||
---
|
||||
|
||||
Runs a block with an environment variable set.
|
||||
|
||||
## Usage
|
||||
```shell
|
||||
> with-env <variable> <block> {flags}
|
||||
```
|
||||
## Signature
|
||||
|
||||
```> with-env (variable) (block)```
|
||||
|
||||
## 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
|
||||
- `variable`: the environment variable to temporarily set
|
||||
- `block`: the block to run once the variable is set
|
||||
|
||||
## Examples
|
||||
Set the MYENV environment variable
|
||||
```shell
|
||||
> with-env [MYENV "my env value"] { echo $nu.env.MYENV }
|
||||
```
|
||||
|
||||
Set by primitive value list
|
||||
Set the MYENV environment variable
|
||||
```shell
|
||||
> with-env [X Y W Z] { echo $nu.env.X $nu.env.W }
|
||||
```
|
||||
> with-env [MYENV "my env value"] { $env.MYENV }
|
||||
```
|
||||
|
||||
Set by single row table
|
||||
Set by primitive value list
|
||||
```shell
|
||||
> with-env [[X W]; [Y Z]] { echo $nu.env.X $nu.env.W }
|
||||
```
|
||||
> with-env [X Y W Z] { $env.X }
|
||||
```
|
||||
|
||||
Set by row(e.g. `open x.json` or `from json`)
|
||||
Set by single row table
|
||||
```shell
|
||||
> echo '{"X":"Y","W":"Z"}'|from json|with-env $it { echo $nu.env.X $nu.env.W }
|
||||
```
|
||||
> with-env [[X W]; [Y Z]] { $env.W }
|
||||
```
|
||||
|
||||
Set by row(e.g. `open x.json` or `from json`)
|
||||
```shell
|
||||
> echo '{"X":"Y","W":"Z"}'|from json|with-env $it { echo $env.X $env.W }
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user