# Configuration
## Quickstart
While Nushell provides many options for managing its startup and configuration, new users
can get started with just a few simple steps:
1. Tell Nushell what editor to use:
```nu
$env.config.buffer_editor = <path_to_your_preferred_editor>
```
For example:
```nu
$env.config.buffer_editor = "code"
# or
$env.config.buffer_editor = "nano"
# or
$env.config.buffer_editor = "hx"
# or
$env.config.buffer_editor = "vi"
# with args
$env.config.buffer_editor = ["emacsclient", "-s", "light", "-t"]
# etc.
```
2. Edit `config.nu` using:
```nu
config nu
```
This will open the current `config.nu` in the editor defined above.
3. Add commands to this file that should run each time Nushell starts. A good first example might be the `buffer_editor` setting above.
You can find a detailed list of available settings using:
```nu
config nu --doc | nu-highlight | less -R
```
4. Save, exit the editor, and start a new Nushell session to load these settings.
That's it! More details are below when you need them ...
---
[[toc]]
::: tip
To view a simplified version of this documentation from inside Nushell, run:
```nu
config nu --doc | nu-highlight | less -R
```
:::
## Configuration Overview
Nushell uses multiple, optional configuration files. These files are loaded in the following order:
1. The first file loaded is `env.nu`, which was historically used to override environment variables. However, the current "best-practice" recommendation is to set all environment variables (and other configuration) using `config.nu` and the autoload directories below.
2. `config.nu` is typically used to override default Nushell settings, define (or import) custom commands, or run any other startup tasks.
3. `*.nu` files in `$nu.vendor-autoload-dirs` are loaded. These directories are intended for vendors' and package managers' startup files.
4. `*.nu` files in `$nu.user-autoload-dirs` are loaded. These files may be used for any startup tasks and are a good way to modularize the configuration.
5. `login.nu` runs commands or handles configuration that should only take place when Nushell is running as a login shell.
By default, `env.nu`, `config.nu`, and `login.nu` are read from the `$nu.default-config-dir` directory. For example:
```nu
$nu.default-config-dir
# macOS
# => /Users/me/Library/Application Support/nushell
# Linux
# => /home/me/.config/nushell
# Windows
# => C:\Users\me\AppData\Roaming\nushell
```
The first time Nushell is launched, it will create the configuration directory and an empty (other than comments) `env.nu` and `config.nu`.
::: tip
You can quickly open `config.nu` in your default text editor using the `config nu` command. Likewise, the `config env` command will open `env.nu`.
This requires that you have configured a default editor using either:
- Nushell's `$env.config.buffer_editor` setting
- The `$env.VISUAL` or `$env.EDITOR` environment variables
For example, place this in your `config.nu` to edit your files in Visual Studio Code:
```nu
$env.config.buffer_editor = 'code'
```
:::
## Common Configuration Tasks in `config.nu`:
::: tip
Some users will prefer a "monolithic" configuration file with most or all startup tasks in one place. `config.nu` can be used for this purpose.
Other users may prefer a "modular" configuration where each file handles a smaller, more focused set of tasks. Files in the autoload dirs can be used to create this experience.
:::
`config.nu` is commonly used to:
- Set [environment variables](#set-environment-variables) for Nushell and other applications
- Set Nushell settings in [`$env.config`](#nushell-settings-in-the-envconfig-record)
- Load modules or source files so that their commands are readily available
- Run any other applications or commands at startup
## Set Environment Variables
::: tip See Also
The [Environment](./environment.md) Chapter covers additional information on how to set and access environment variables.