You can also set environment variables at startup so they are available for the duration of Nushell running. To do this, set an environment variable inside [the Nu configuration file](configuration.md).
For example:
```nu
# In config.nu
$env.FOO = 'BAR'
```
## Environment Variable Conversions
You can set the `ENV_CONVERSIONS` environment variable to convert other environment variables between a string and a value.
For example, the [default environment config](https://github.com/nushell/nushell/blob/main/crates/nu-utils/src/default_files/default_env.nu) includes conversion of PATH (and Path used on Windows) environment variables from a string to a list.
After both `env.nu` and `config.nu` are loaded, any existing environment variable specified inside `ENV_CONVERSIONS` will be translated according to its `from_string` field into a value of any type.
External tools require environment variables to be strings, therefore, any non-string environment variable needs to be converted first.
The conversion of value -> string is set by the `to_string` field of `ENV_CONVERSIONS` and is done every time an external command is run.
Let's illustrate the conversions with an example.
Put the following in your config.nu:
```nu
$env.ENV_CONVERSIONS = {
# ... you might have Path and PATH already there, add:
FOO : {
from_string: { |s| $s | split row '-' }
to_string: { |v| $v | str join '-' }
}
}
```
Now, within a Nushell instance:
```nu
with-env { FOO : 'a-b-c' } { nu } # runs Nushell with FOO env. var. set to 'a-b-c'
$env.FOO
# => 0 a
# => 1 b
# => 2 c
```
You can see the `$env.FOO` is now a list in a new Nushell instance with the updated config.
You can also test the conversion manually by
```nu
do $env.ENV_CONVERSIONS.FOO.from_string 'a-b-c'
```
Now, to test the conversion list -> string, run:
```nu
nu -c '$env.FOO'
# => a-b-c
```
Because `nu` is an external program, Nushell translated the `[ a b c ]` list according to `ENV_CONVERSIONS.FOO.to_string` and passed it to the `nu` process.
Running commands with `nu -c` does not load the config file, therefore the env conversion for `FOO` is missing and it is displayed as a plain string -- this way we can verify the translation was successful.
You can also run this step manually by `do $env.ENV_CONVERSIONS.FOO.to_string [a b c]`
_(Important! The environment conversion string -> value happens **after** the env.nu and config.nu are evaluated. All environment variables in env.nu and config.nu are still strings unless you set them manually to some other values.)_
## Removing Environment Variables
You can remove an environment variable only if it was set in the current scope via [`hide-env`](/commands/docs/hide-env.md):
```nu
$env.FOO = 'BAR'
# => ...
hide-env FOO
```
The hiding is also scoped which both allows you to remove an environment variable temporarily and prevents you from modifying a parent environment from within a child scope:
```nu
$env.FOO = 'BAR'
do {
hide-env FOO
# $env.FOO does not exist
}
$env.FOO
# => BAR
```