---
title: export-env
categories: |
env
version: 0.104.0
env: |
Run a block and preserve its environment in a current scope.
usage: |
Run a block and preserve its environment in a current scope.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->
# `export-env` for [env](/commands/categories/env.md)
<div class='command-title'>Run a block and preserve its environment in a current scope.</div>
## Signature
```> export-env {flags} (block)```
## Parameters
- `block`: The block to run to set the environment.
## Input/output types:
| input | output |
| ------- | ------- |
| nothing | nothing |
## Examples
Set an environment variable
```nu
> export-env { $env.SPAM = 'eggs' }
```
Set an environment variable and examine its value
```nu
> export-env { $env.SPAM = 'eggs' }; $env.SPAM
eggs
```
## Notes
This command is a parser keyword. For details, check:
https://www.nushell.sh/book/thinking_in_nu.html