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
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Shells
    • Strings
    • System
    • Viewers

to dotenv for formats

Convert a record into .env text.

Command Type

built-in

Signature

> to dotenv {flags}

Input/output types:

inputoutput
recordstring

Examples

Write a record as .env text, quoting values that need it.

> {PORT: 8080, NAME: 'my app', GREETING: "it's"} | to dotenv
PORT=8080
NAME='my app'
GREETING="it's"

Round-trip a record through .env text.

> {URL: 'http://${HOST}/', NOTE: "two\nlines"} | to dotenv | from dotenv
╭──────┬─────────────────╮
│ URL  │ http://${HOST}/ │
│ NOTE │ two             │
│      │ lines           │
╰──────┴─────────────────╯

Save a record to a .env file.

> {PORT: 8080, NAME: 'my app'} | save .env

Notes

Each value is written as an external command would see it, so a PATH list is joined with the path separator and the to_string conversions in $env.ENV_CONVERSIONS apply, and null is written as an empty value. A value of plain characters is written bare; any other is single-quoted, or double-quoted with escapes when it holds a ' or a line break, so from dotenv reads back the same text. save writes a record to a file named like .env, .env.local or prod.env with this command.