Home Explore Blog CI



nushell

commands/docs/export-env.md
194602355527a07b255f83dba189dd9e208f3b6386dd5fb0000000030000040b
---
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

Chunks
818de9fe (1st chunk of `commands/docs/export-env.md`)
Title: export-env: Run a block and preserve its environment.
Summary
The `export-env` command executes a block of code and preserves the resulting environment variables within the current scope. It takes a block as input and modifies the current environment without producing any output.