Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
  • Introduction
  • Installation
    • Default Shell
  • Getting Started
    • Quick Tour
    • Moving Around the System
    • Thinking in Nu
    • Nushell Cheat Sheet
  • Nu Fundamentals
    • Types of Data
    • Loading Data
    • Data Formats
    • Working with SQLite
    • Pipelines
    • Working with Strings
    • Regular Expressions
    • Working with Binary Data
    • Working with Lists
    • Working with Records
    • Working with Numbers
    • Working with Tables
    • Working with Paths
    • Navigating and Accessing Structured Data
    • Special Variables
  • Programming in Nu
    • Custom Commands
    • Aliases
    • Operators
    • Variables
    • Control Flow
    • Scripts
    • Modules
      • Using Modules
      • Creating Modules
    • Overlays
    • Sorting
    • Testing your Nushell Code
    • Debugging Scripts
    • Language Server
    • Best Practices
  • Nu as a Shell
    • Configuration
    • Configuration Reference
    • Environment
    • Stdout, Stderr, and Exit Codes
    • Working with the Terminal
    • Running System (External) Commands
    • How to Configure 3rd Party Prompts
    • Directory Stack
    • Reedline, Nu's Line Editor
    • Custom Completions
    • Externs
    • Coloring and Theming in Nu
    • Hooks
    • Background Jobs
  • Coming to Nu
    • Coming from Bash
    • Coming from CMD.EXE
    • Coming from PowerShell
    • Nu map from other shells and domain specific languages
    • Nu Map from Imperative Languages
    • Nu Map from Functional Languages
    • Nushell operator map
  • Design Notes
    • How Nushell Code Gets Run
  • (Not So) Advanced
    • Standard Library
      • std/assert
      • std/bench
      • std/clip
      • std/config
      • std/dt
      • std/formats
      • std/help
      • std/input
      • std/iter
      • std/log
      • std/math
      • std/random
      • std/util
      • std/xml
      • std-rfc
    • Dataframes
      • Dataframe Operations
      • Column Selectors
      • Math Expressions
      • String Expressions
      • Dates and Times in Dataframes
      • Masks and Conditionals
      • Aggregations and Window Functions
    • Metadata
    • Creating Your Own Errors
    • Parallelism
    • Plugins
    • explore
    • Building TUIs with tui
    • MCP Server

std/config

The std/config module has three commands that return values for your configuration. None of them changes anything by itself. You assign what they return in config.nu or env.nu.

use std/config

config dark-theme and config light-theme

These return a record of colors for $env.config.color_config, one meant for terminals with a dark background and one for a light background:

$env.config.color_config = (config light-theme)

See Working on Light Background Terminal for more.

config env-conversions

config env-conversions returns a record of ready-made conversions for $env.ENV_CONVERSIONS. In Nushell 0.117.0 it has a single entry, path, for variables that hold a list of paths:

config env-conversions
# => ╭──────┬───────────────────╮
# => │ path │ {record 2 fields} │
# => ╰──────┴───────────────────╯

path is a record with the two closures that ENV_CONVERSIONS expects:

  • from_string splits the string at the path separator, (char esep), which is : or ; on Windows. Then it expands each path with path expand --no-symlink, which makes it absolute and expands ~ but doesn't resolve symbolic links.
  • to_string expands each path the same way and joins them with the separator.

Use it for a variable such as XDG_DATA_DIRS, which Nushell doesn't convert on its own:

$env.ENV_CONVERSIONS = $env.ENV_CONVERSIONS | merge {
    XDG_DATA_DIRS: (config env-conversions).path
}
$env.XDG_DATA_DIRS ++= ["~/.local/share"]
$env.XDG_DATA_DIRS
# => ╭───┬──────────────────╮
# => │ 0 │ /usr/share       │
# => │ 1 │ /usr/local/share │
# => │ 2 │ ~/.local/share   │
# => ╰───┴──────────────────╯
^sh -c 'echo $XDG_DATA_DIRS'
# => /usr/share:/usr/local/share:/home/me/.local/share

The list keeps a path as you added it. The ~ is expanded only when to_string turns the list back into a string for an external program. This is the same pair of closures as the XDG_DATA_DIRS example in ENV_CONVERSIONS.

Edit this page on GitHub
Contributors: fdncred
Prev
std/clip
Next
std/dt