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

Plugins

Nu can be extended using plugins. Plugins behave much like Nu's built-in commands, with the added benefit that they can be added separately from Nu itself.

Important

Plugins communicate with Nushell using the nu-plugin protocol. This protocol is versioned, and plugins must use the same nu-plugin version provided by Nushell.

When updating Nushell, please make sure to also update any plugins that you have registered. Updating Plugins shows the errors you get from a plugin built for another version.

  • Overview
    • Core Plugin Quickstart
  • Installing Plugins
    • Core Plugins
    • Third-party Plugins
  • Registering Plugins
    • Importing Plugins
    • Loading plugins without the registry
    • Plugin Search Path
    • Updating Plugins
    • The plugin registry file
  • Managing Plugins
    • Plugin Lifecycle
    • Plugin Garbage Collector
    • Plugin configuration
  • Removing Plugins
  • Using the core plugins
    • The polars plugin
    • The formats plugin
    • The gstat plugin
    • The query plugin
    • The inc plugin
  • For Plugin Developers
    • Examples
    • Debugging
    • Developer Help
    • More details

Overview

  • In order to use a plugin, it needs to be:

    • Installed
    • Added
    • Imported

There are two types of plugins:

  • "Core plugins" are officially maintained and are usually installed with Nushell, in the same directory as the Nushell executable.
  • Third-party plugins are also available from many sources.

The $NU_PLUGIN_DIRS constant or $env.NU_PLUGIN_DIRS environment variable can be used to set the search-path for plugins.

Core Plugin Quickstart

To begin using the Polars plugin:

  1. Most package managers will automatically install the core plugins with Nushell. A notable exception, however, is cargo. If you installed Nushell using cargo, see Installing Core Plugins below.

  2. Make sure the plugin search path includes the directory where the plugins are installed. By default, it contains the plugins directory in your Nushell configuration directory and the directory of the Nushell binary itself, so core plugins installed alongside Nushell are found automatically:

    $NU_PLUGIN_DIRS
    # => ╭───┬────────────────────────────────────╮
    # => │ 0 │ /home/user/.config/nushell/plugins │
    # => │ 1 │ /home/user/.cargo/bin              │
    # => ╰───┴────────────────────────────────────╯

    If your plugins are installed somewhere else, add that directory in your startup config:

    const NU_PLUGIN_DIRS = [
      ...$NU_PLUGIN_DIRS
      ($nu.home-dir | path join "my-plugins")
    ]
  3. Add the plugin to the plugin registry. This only needs to be done one time. The name is the name of the plugin file, including its extension:

    # On Unix/Linux platforms:
    plugin add nu_plugin_polars
    # Or on Windows
    plugin add nu_plugin_polars.exe
    
    plugin list # Confirm it was added to the registry

    Alternatively, if the plugin's directory is not in the plugin search path, you can still use an absolute path:

    plugin add ~/.local/share/rust/cargo/bin/nu_plugin_polars
  4. Import the plugin (to begin using it immediately) or restart Nushell. All plugins in the registry are automatically imported when Nushell starts:

    # The name of the plugin, without the leading `nu_plugin` nor any extension
    plugin use polars
  5. Confirm the plugin is working:

    ls | polars into-df | describe
    # => polars_dataframe
Polars value types

polars_dataframe is one of several custom value types that the Polars plugin defines. describe shows these names:

describe nameProduced by
polars_dataframepolars into-df, polars collect, polars open --eager
polars_lazyframepolars into-lazy, and polars open without --eager for most file formats
polars_expressionpolars col, polars lit, polars otherwise, and other expression commands
polars_group_bypolars group-by
polars_whenpolars when, until polars otherwise turns it into an expression
polars_datatypepolars into-dtype
polars_schemapolars into-schema
polars_selectorthe polars selector commands, such as polars selector all

The DataFrames chapter explains how these types work together.

Installing Plugins

Core Plugins

Nushell ships with a set of officially maintained plugins which includes:

  • polars: Extremely fast columnar operations using DataFrames via the Polars Library. See the DataFrames Chapter for more details.
  • formats: Support for several additional data formats - EML, ICS, INI, plist, and VCF.
  • gstat: Returns information on the status of a Git repository as Nushell structured data.
  • query: Support for querying XML (via XPath), JSON, HTML (via CSS selectors), and web page metadata
  • inc: Increment a value or version (e.g., semver). This plugin acts as both an end-user plugin as well as a simple developer example of how to create a plugin.

Using the core plugins describes the commands each of these plugins adds.

Nushell also ships with several plugins that serve as examples or tools for plugin developers. These include nu_plugin_example, nu_plugin_custom_values, and nu_plugin_stress_internals.

Core plugins are typically distributed with the Nushell release and should already be installed in the same directory as the Nushell executable. If this is the case on your system, core plugins should be using correct nu-plugin protocol version. If your package management system installs them separately, please make sure to update the core plugins whenever Nushell itself is updated.

Installing using Cargo

For example, when installing or upgrading Nushell directly from crates.io using cargo install nu --locked, the corresponding core plugins for that version may also be installed or updated using cargo install nu_plugin_<plugin_name> --locked.

To install all of the default (non-developer) plugins, from within Nushell run:

[ nu_plugin_inc
  nu_plugin_polars
  nu_plugin_gstat
  nu_plugin_formats
  nu_plugin_query
] | each { cargo install $in --locked } | ignore

Third-party Plugins

You can find third-party plugins on crates.io, online Git repositories, awesome-nu, and other sources. As with any third-party code you run on your system, please make sure you trust its source.

To install a third-party plugin on your system, you first need to make sure the plugin uses the same version of Nu as your system:

  • Confirm your Nushell version with the version command
  • Confirm the version the plugin requires by checking its Cargo.toml file

To install a plugin by name from crates.io, run:

cargo install nu_plugin_<plugin_name> --locked

When installing from a repository (e.g., GitHub), run the following from inside the cloned repository:

cargo install --path . --locked

This will create a binary file that can be used to add the plugin.

Cargo installation location

By default, binaries installed with cargo install are placed in your home directory under .cargo/bin. However, this can change depending on how your system is configured.

Registering Plugins

To add a plugin to the plugin registry file, call the plugin add command to tell Nu where to find it.

Note

The plugin file name must start with nu_plugin_, Nu uses this filename prefix to identify plugins.

  • Linux and macOS:

    plugin add ./my_plugins/nu_plugin_cool
  • Windows:

    plugin add .\my_plugins\nu_plugin_cool.exe

When plugin add is called, Nu:

  • Runs the plugin binary
  • Communicates via the plugin protocol in order to ensure compatibility and to get a list of all of the commands it supports
  • This plugin information is then saved to the plugin registry file ($nu.plugin-path), which acts as a cache

plugin add looks for the file in the current directory first, then in the plugin search path. It saves the file's full path with symlinks resolved, and names the plugin after the file, without nu_plugin_ and without the extension: nu_plugin_cool.exe becomes cool. If a plugin with that name is already in the registry, the new entry replaces it.

Nu runs a script file with an interpreter that it picks from the extension, such as python for .py and nu for .nu. The contributor book has the full list. For any other interpreter, or a different path to one, pass --shell:

plugin add --shell /usr/bin/python3 ./nu_plugin_cool.py

plugin add creates the registry file and its parent directories if they don't exist. --plugin-config writes to another registry file instead. When nu runs with --no-config-file, it uses no registry file, so plugin add fails unless you give it --plugin-config:

plugin add nu_plugin_gstat
# => Error: nu::shell::error
# =>
# =>   × Plugin registry file not set
# =>    ╭─[source:1:1]
# =>  1 │ plugin add nu_plugin_gstat
# =>    · ─────┬────
# =>    ·      ╰── pass --plugin-config explicitly here
# =>    ╰────
# =>   help: you may be running `nu` with --no-config-file

Importing Plugins

Once added to the registry, the next time nu is started, the plugin will be imported and available in that session.

You can also immediately import (or reload) a plugin in the current session by calling plugin use. In this case, the name of the plugin (rather than the filename) is used without the nu_plugin prefix:

plugin use cool

plugin use also accepts the plugin's filename, as a path from the current directory or a full path. It only loads what the registry file holds for that plugin and never runs the plugin to read new signatures, so a plugin you haven't added gives a "Plugin not found" error. If the plugin is running, plugin use stops it, so the next call starts the plugin again. Pass --plugin-config to read a registry file other than $nu.plugin-path.

It is not necessary to add plugin use statements to your config file. All previously registered plugins are automatically loaded at startup.

Note

plugin use is a parser keyword, so when evaluating a script, it will be evaluated first. This means that while you can execute plugin add and then plugin use at the REPL on separate lines, you can't do this in a single script. To run a script with plugins you haven't registered, use nu --plugins.

Loading plugins without the registry

The --plugins option of nu loads plugin executables for one session, without a registry file. Pass a list of files:

nu --plugins '[./my_plugins/nu_plugin_cool]'

The --plugins option can also be repeated, once for each plugin:

nu --plugins ./my_plugins/nu_plugin_cool --plugins ./my_plugins/nu_plugin_other

Inside the brackets, separate the paths with spaces or with commas, and put double quotes around a path that contains spaces: --plugins '["./my plugins/nu_plugin_cool", ./nu_plugin_other]'. Nu resolves a relative path against the directory you start it from.

Nu starts each of these plugins at startup to read its signatures, so they show as running in plugin list until the garbage collector stops them. They load even with --no-config-file, which skips the registry file, and nu never writes them to the registry file.

Plugin Search Path

Nushell includes two list variables that can be used to set a search path for plugins. This only applies when registering plugins with plugin add, but it can be a nice shortcut if you commonly add and remove plugins.

  • const NU_PLUGIN_DIRS: A constant which takes effect immediately when set. However, as a constant, only certain commands may be used with it. It can be updated, for example, as seen in the QuickStart above.
  • $env.NU_PLUGIN_DIRS: An environment variable which is mutable and can accept any command that updates its list. plugin add reads it when it runs, so a change applies to the next plugin add, even later in the same script.

plugin add tries the current directory first, then the directories in $NU_PLUGIN_DIRS in order, then those in $env.NU_PLUGIN_DIRS, and uses the first match. A relative directory in either list is resolved against the current directory.

Updating Plugins

When updating a plugin, it is important to run plugin add again just as above to load the new signatures from the plugin and allow Nu to rewrite them to the plugin file ($nu.plugin-path). You can then plugin use to get the updated signatures within the current session.

Before 1.0, a plugin has to be built for the same minor version of Nushell, so a plugin built for 0.116 doesn't work with Nushell 0.117. Nu checks the version each time it starts a plugin, during plugin add and whenever you run a command of a plugin that isn't running. It doesn't check at startup, because the signatures it loads then come from the registry file. An outdated plugin therefore loads without complaint, and its commands fail when you run them, with an error like:

Plugin failed to load: Plugin `gstat` is compiled for nushell version 0.116.0, which is not compatible with version 0.117.0

Install the version of the plugin that matches your Nushell, then plugin add it again.

An update can also change the format of the registry file itself. At startup, Nu skips each registry entry it can't read. For each one, it reports "The registered plugin data for NAME is invalid" along with the plugin add command that fixes it, and then it sums up:

Failed to load 1 plugin entry from /home/me/.config/nushell/plugin.msgpackz

with the help text "run plugin list and re-add outdated plugins with plugin add". plugin list shows those entries with the status invalid.

The plugin registry file

The registry file at $nu.plugin-path is MessagePack data compressed with Brotli. open decodes it with from msgpackz, like any .msgpackz file, so you can look inside:

open $nu.plugin-path | get plugins | columns
# => ╭───┬──────────╮
# => │ 0 │ name     │
# => │ 1 │ filename │
# => │ 2 │ shell    │
# => │ 3 │ metadata │
# => │ 4 │ commands │
# => ╰───┴──────────╯

Change it only through plugin add and plugin rm. Saving the decoded data back with to msgpackz doesn't produce a file that Nu can load. If Nu can't decompress or decode the file at startup, it loads no plugins from it and reports "Error while reading plugin registry file", with the help "you might try deleting the file and registering all of your plugins again". The plugin commands that read the file fail with "Failed to load plugin file" and similar help. Older versions of Nushell kept registered plugins in a plugin.nu file of register commands. Nu no longer reads that format. Pointing nu --plugin-config at a .nu file gives the error "Wrong plugin file format", with the label ".nu plugin files are no longer supported".

Managing Plugins

plugin on its own only prints its help text, which lists the subcommands: plugin add, plugin list, plugin rm, plugin stop, and plugin use.

Installed plugins are displayed using plugin list:

plugin list
# => ╭───┬───────┬─────────┬─────────┬───────┬───────────────────────┬───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
# => │ # │ name  │ version │ status  │  pid  │       filename        │ shell │           commands                                                                                                   │
# => ├───┼───────┼─────────┼─────────┼───────┼───────────────────────┼───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
# => │ 0 │ gstat │ 0.116.0 │ loaded  │       │ .../nu_plugin_gstat   │       │ ╭───┬───────┬──────────────────────────────╮                                                                         │
# => │   │       │         │         │       │                       │       │ │ # │ name  │         description          │                                                                         │
# => │   │       │         │         │       │                       │       │ ├───┼───────┼──────────────────────────────┤                                                                         │
# => │   │       │         │         │       │                       │       │ │ 0 │ gstat │ Get the git status of a repo │                                                                         │
# => │   │       │         │         │       │                       │       │ ╰───┴───────┴──────────────────────────────╯                                                                         │
# => │ 1 │ query │ 0.116.0 │ running │ 27312 │ .../nu_plugin_query   │       │ ╭───┬────────────────────┬─────────────────────────────────────────────────────────────────────────────────────────╮ │
# => │   │       │         │         │       │                       │       │ │ # │        name        │                                       description                                       │ │
# => │   │       │         │         │       │                       │       │ ├───┼────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────┤ │
# => │   │       │         │         │       │                       │       │ │ 0 │ query              │ Show all the query commands                                                             │ │
# => │   │       │         │         │       │                       │       │ │ 1 │ query json         │ execute json query on json file (open --raw <file> | query json 'query string')         │ │
# => │   │       │         │         │       │                       │       │ │ 2 │ query web          │ execute selector query on html/web                                                      │ │
# => │   │       │         │         │       │                       │       │ │ 3 │ query webpage-info │ uses the webpage crate to extract info from html: title, description, language, links,  │ │
# => │   │       │         │         │       │                       │       │ │   │                    │ RSS feeds, Opengraph, Schema.org, and more                                              │ │
# => │   │       │         │         │       │                       │       │ │ 4 │ query xml          │ Execute XPath 1.0 query on XML input                                                    │ │
# => │   │       │         │         │       │                       │       │ ╰───┴────────────────────┴─────────────────────────────────────────────────────────────────────────────────────────╯ │
# => ╰───┴───────┴─────────┴─────────┴───────┴───────────────────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

plugin list merges two sources: the plugins loaded into the current session (the engine), and the entries in the registry file. The shell column holds the interpreter given to plugin add --shell, and is empty otherwise. For a plugin in both places, version, filename, shell, and commands come from the engine. For a plugin only in the registry file, they come from the file. The status column compares the two:

StatusMeaning
addedIn the registry file, but not loaded into this session yet (added with plugin add, not used)
loadedIn both, with the same details, and not running
runningRunning now, with its process ID in pid. This status wins over all the others
modifiedIn both, but the registry entry has a different filename, shell, or command list
removedLoaded into this session, but no longer in the registry file (after plugin rm)
invalidThe registry entry can't be read, and the plugin needs to be added again

For example, a plugin you've just added stays added until you plugin use it or start a new session, and one you remove stays listed as removed until the session ends:

plugin add nu_plugin_gstat
plugin list | select name status
# => ╭───┬───────┬────────╮
# => │ # │ name  │ status │
# => ├───┼───────┼────────┤
# => │ 0 │ gstat │ added  │
# => ╰───┴───────┴────────╯
plugin rm gstat
plugin list | select name status
# => ╭───┬───────┬─────────╮
# => │ # │ name  │ status  │
# => ├───┼───────┼─────────┤
# => │ 0 │ gstat │ removed │
# => ╰───┴───────┴─────────╯

plugin list --engine (-e) lists only what's loaded in the session, and plugin list --registry (-r) lists only the registry file, where every status is added or invalid. --plugin-config reads another registry file. Under nu --no-config-file, a plain plugin list shows the session's plugins without an error, but --registry needs --plugin-config.

All of the commands from installed plugins are available in the current scope:

scope commands | where type == "plugin"

which reports a plugin command with the type plugin, and its path column holds the plugin's executable. query db is built into Nushell, and the query plugin adds the other query subcommands:

which "query json" "query db" | select command type
# => ╭───┬────────────┬──────────╮
# => │ # │  command   │   type   │
# => ├───┼────────────┼──────────┤
# => │ 0 │ query json │ plugin   │
# => │ 1 │ query db   │ built-in │
# => ╰───┴────────────┴──────────╯
which "query json" | get path.0
# => /home/me/.cargo/bin/nu_plugin_query

In help, the list of a command's subcommands marks each one that comes from a plugin with (plugin), and the help for a plugin command shows plugin under Command Type:

help query
# => Show all the query commands
# =>
# => Usage:
# =>   > query
# =>
# => Subcommands:
# =>   query db - Query a SQLite database with SQL statements.
# =>   query json (plugin) - execute json query on json file (open --raw <file> | query json 'query string')
# =>   query web (plugin) - execute selector query on html/web
# =>   query webpage-info (plugin) - uses the webpage crate to extract info from html: title, description, language, links, RSS feeds, Opengraph, Schema.org, and more
# =>   query xml (plugin) - Execute XPath 1.0 query on XML input
# =>
# => Flags:
# =>   -h, --help: Display the help message for this command
# =>
# => Command Type:
# =>   > plugin

version also lists the plugins, in its installed_plugins field, as one string of names and versions separated by commas:

version | get installed_plugins
# => polars 0.117.0, query 0.117.0

The field lists the plugins loaded into the current session, running or not. A plugin you have only registered with plugin add appears after plugin use or a restart, and one you remove with plugin rm stays until the session ends. A plugin that didn't report a version is listed by its name alone.

The other fields of version

version returns one record. Besides installed_plugins, it has:

  • version, major, minor, patch: the Nushell version as a string and as three integers. pre and build appear only for a version with a pre-release or build-metadata part.
  • branch and commit_hash: the Git branch and commit the binary was built from. commit_hash, and build_pr for a build made from a pull request, appear only when the build set them.
  • build_os, build_target, build_time, build_rust_channel: the platform and target triple, when the binary was built, and whether it's a release or debug build.
  • rust_version, rust_channel, cargo_version: the Rust toolchain that built it.
  • allocator: the memory allocator, standard in this version.
  • features: the Cargo features compiled in, as one comma-separated string. Plugins need the plugin feature.
  • experimental_options: each experimental option and whether it's on, as name=true or name=false, separated by commas.

version can run at parse time, so a constant can hold its result:

const v = (version)
$v.minor
# => 117

Plugin Lifecycle

Plugins stay running while they are in use, and are automatically stopped by default after a period of time of inactivity. This behavior is managed by the plugin garbage collector. To manually stop a plugin, call plugin stop with its name:

For example, run the query command from the corresponding plugin, then check its status status:

http get http://example.com | query web --document --query body | ignore
plugin list | where name == query | select name status
# => ╭───┬───────┬─────────╮
# => │ # │ name  │ status  │
# => ├───┼───────┼─────────┤
# => │ 0 │ query │ running │
# => ╰───┴───────┴─────────╯

Now stop the plugin manually, and we can see that it is no longer running:

plugin stop query
plugin list | where name == query | select name status
# => ╭───┬───────┬────────╮
# => │ # │ name  │ status │
# => ├───┼───────┼────────┤
# => │ 0 │ query │ loaded │
# => ╰───┴───────┴────────╯

plugin stop also accepts the plugin's filename, as a path from the current directory or a full path. Stopping a plugin that is loaded but not running does nothing. A name that matches no plugin loaded in the session is an error:

plugin stop cool
# => Error: nu::shell::error
# =>
# =>   × Failed to stop the `cool` plugin
# =>    ╭─[source:1:13]
# =>  1 │ plugin stop cool
# =>    ·             ──┬─
# =>    ·               ╰── couldn't find a plugin with this name
# =>    ╰────
# =>   help: you may need to `plugin add` the plugin first

A stopped plugin starts again the next time you run one of its commands.

Plugin Garbage Collector

As mentioned above, Nu comes with a plugin garbage collector which automatically stops plugins that are not actively in use after a period of time (by default, 10 seconds). This behavior is fully configurable:

$env.config.plugin_gc = {
    # Settings for plugins not otherwise specified:
    default: {
        enabled: true # set to false to never automatically stop plugins
        stop_after: 10sec # how long to wait after the plugin is inactive before stopping it
    }
    # Settings for specific plugins, by plugin name
    # (i.e. what you see in `plugin list`):
    plugins: {
        gstat: {
            stop_after: 1min
        }
        inc: {
            stop_after: 0sec # stop as soon as possible
        }
        example: {
            enabled: false # never stop automatically
        }
    }
}

A record under plugins doesn't inherit from default. A key it leaves out takes the built-in value (enabled: true, stop_after: 10sec), not the one in default:

$env.config.plugin_gc = {
    default: { enabled: false, stop_after: 1min }
    plugins: { gstat: { stop_after: 5sec } }
}
$env.config.plugin_gc.plugins.gstat
# => ╭────────────┬──────╮
# => │ enabled    │ true │
# => │ stop_after │ 5sec │
# => ╰────────────┴──────╯

stop_after must not be negative:

$env.config.plugin_gc.default.stop_after = -1sec
# => Error: nu::shell::invalid_config
# =>
# =>   × Encountered 1 error(s) when updating config
# =>
# => Error: nu::shell::invalid_value
# =>
# =>   × Invalid value for $env.config.plugin_gc.default.stop_after
# =>    ╭─[source:1:44]
# =>  1 │ $env.config.plugin_gc.default.stop_after = -1sec
# =>    ·                                            ──┬──
# =>    ·                                              ╰── expected a non-negative duration, but got -1sec
# =>    ╰────

For information on when a plugin is considered to be active, see the relevant section in the contributor book.

Plugin configuration

Some plugins read settings from $env.config.plugins, in a key named after the plugin as plugin list shows it. The value can be anything the plugin expects, usually a record:

$env.config.plugins.motd = { message: "Nushell rocks!" }

The value can also be a closure. Nu runs it each time the plugin asks for its settings, with no arguments, in the scope of the command call, and hands the plugin the result. That lets the settings depend on the environment at the time of the call:

$env.config.plugins.motd = {|| { message: $"Hello from (pwd)" } }

If the closure fails, the plugin receives the error as its configuration value, and what happens next is up to the plugin. None of the core plugins reads $env.config.plugins. Of the plugins that ship with Nushell, only the developer example nu_plugin_example does, in its example config command. The experimental built-in clip commands also look here, under clip, clipboard, or nu_plugin_clipboard, so that settings written for the third-party nu_plugin_clipboard keep working. See Clipboard.

Removing Plugins

To remove a plugin, call plugin rm <plugin_name>. For example, if you previously added the plugin ~/.cargo/bin/nu_plugin_gstat, its name would be gstat. To remove it:

plugin rm gstat

You can confirm the name of a plugin by running plugin list. plugin rm also accepts the filename, as a path from the current directory or a full path, such as plugin rm ~/.cargo/bin/nu_plugin_gstat.

Running plugin rm removes the plugin from the registry so that it will not be loaded the next time Nushell starts. However, any commands created by the plugin remain in scope until the current Nushell session ends.

If the registry file has no such plugin, plugin rm fails:

plugin rm cool
# => Error: nu::shell::error
# =>
# =>   × Failed to remove the `cool` plugin
# =>    ╭─[source:1:11]
# =>  1 │ plugin rm cool
# =>    ·           ──┬─
# =>    ·             ╰── couldn't find a plugin with this name in the registry file
# =>    ╰────

plugin rm --force (-f) skips that error, which helps in scripts that remove a plugin that may not be there. Like plugin add, plugin rm takes --plugin-config to edit a registry file other than $nu.plugin-path.

Using the core plugins

Each command below links to its reference page, which lists the flags.

Warning

An error from a plugin can print the environment variables of the nu process, including any API keys or tokens they hold. Such an error points at "Host Environment Variables" instead of at your code. Check error output before you share it, for example in a bug report.

The polars plugin

The polars plugin adds the polars commands for working with dataframes. The DataFrames chapter covers them, and the "Polars value types" box in the quickstart lists the kinds of values they return.

The formats plugin

The formats plugin reads five more file formats: email messages (.eml), iCalendar files (.ics), INI files (.ini), property lists (.plist), and vCard contacts (.vcf). The only one it writes is the property list. With the plugin loaded, open runs the matching from command for each of these extensions, and save runs to plist for a .plist file. Saving structured data to one of the other extensions fails, because there's no to command for it.

For a file with a different extension, pipe open --raw into the command, as in open --raw message.txt | from eml. from eml, from ics, from ini, and from vcf take text and don't convert values, so a port number or a date comes back as a string. Use into int or into datetime on the fields you need. from plist is different, since property lists store typed values.

Email messages

from eml turns one email message into a record:

let message = "From: Alice <[email protected]>
To: Bob <[email protected]>, [email protected]
Subject: Lunch
X-Priority: 3

Are we still on for Friday? I can book a table for noon."
$message | from eml
# => ╭────────────┬────────────────────────────────────────────────────╮
# => │ Subject    │ Lunch                                              │
# => │ From       │ {record 2 fields}                                  │
# => │ To         │ [table 2 rows]                                     │
# => │ X-Priority │ 3                                                  │
# => │ Body       │ Are we still on for Friday? I can book a table for │
# => ╰────────────┴────────────────────────────────────────────────────╯
$message | from eml | get To | to nuon
# => [[Name, Address]; [Bob, "[email protected]"], [null, "[email protected]"]]

The record starts with Subject, From, and To, then has the other headers in the order they appear, then Body. The headers that hold addresses (From, To, Reply-To, Delivered-To, X-Original-To, and Return-Path) become a record with Name and Address, or a list of those records when there are several addresses. Name is null for a bare address. Every other header, Cc included, stays a string, with encoded words such as =?UTF-8?B?...?= decoded. A header with an empty value becomes null. Header names are case-sensitive, so a subject: header is an ordinary header and doesn't fill in Subject. When a header appears more than once, as Received usually does, the record keeps the last one.

Body is the text after the headers, exactly as it is in the file. Quoted-printable text and MIME parts aren't decoded. It's also cut to the first 50 bytes, which is why the body above stops at "for". --preview-body (-b) sets a different limit in bytes. The cut never splits a character, and a negative limit gives an empty body. To keep the whole body, pass a limit larger than the message, such as --preview-body 1_000_000.

Text that doesn't start with a header fails with "Can't convert to structured eml data". End the headers with a blank line, even when the message has no body.

Calendars and contacts

from ics reads iCalendar data and from vcf reads vCard contacts. Both return a list with one record for each BEGIN:VCALENDAR or BEGIN:VCARD block, and both turn each property line in the block into a record with three fields:

  • name: the property name, such as SUMMARY or EMAIL.
  • value: the value, as a string. Dates such as 20261120T120000 aren't converted.
  • params: null, or a record that maps each parameter to a list of strings.

Before parsing, both commands join each continuation line, one that starts with a space or a tab, to the line before it.

A contact record has a single column, properties. A calendar record has properties for the calendar itself and a list for each kind of component: events, alarms, to-Dos, journals, free-busys, and timezones. Each component is a record with its own properties. Events and to-dos also have an alarms list, and time zones have a transitions list.

let calendar = 'BEGIN:VCALENDAR
BEGIN:VEVENT
SUMMARY:Lunch with the team
DTSTART;TZID=America/Chicago:20261120T120000
ATTENDEE;ROLE=CHAIR;CN=Bob:mailto:[email protected]
END:VEVENT
END:VCALENDAR'
$calendar | from ics | get 0.events.0.properties
# => ╭───┬──────────┬────────────────────────┬───────────────────╮
# => │ # │   name   │         value          │      params       │
# => ├───┼──────────┼────────────────────────┼───────────────────┤
# => │ 0 │ SUMMARY  │ Lunch with the team    │                   │
# => │ 1 │ DTSTART  │ 20261120T120000        │ {record 1 field}  │
# => │ 2 │ ATTENDEE │ mailto:[email protected] │ {record 2 fields} │
# => ╰───┴──────────┴────────────────────────┴───────────────────╯
$calendar | from ics | get 0.events.0.properties.2.params | to nuon
# => {ROLE: [CHAIR], CN: [Bob]}

To get one record per event, with a column for each property, turn each properties table around with transpose:

$calendar | from ics | get 0.events | each {|event|
    $event.properties | select name value | transpose --header-row --as-record
}
# => ╭───┬─────────────────────┬─────────────────┬────────────────────────╮
# => │ # │       SUMMARY       │     DTSTART     │        ATTENDEE        │
# => ├───┼─────────────────────┼─────────────────┼────────────────────────┤
# => │ 0 │ Lunch with the team │ 20261120T120000 │ mailto:[email protected] │
# => ╰───┴─────────────────────┴─────────────────┴────────────────────────╯

transpose keeps only the first of several properties with the same name, and a contact often has more than one EMAIL or TEL. Collect those with where instead:

let cards = 'BEGIN:VCARD
FN:Alice Example
EMAIL;TYPE=work:[email protected]
EMAIL;TYPE=home:[email protected]
END:VCARD
BEGIN:VCARD
FN:Bob Example
EMAIL:[email protected]
END:VCARD'
$cards | from vcf | each {|card|
    let props = $card.properties
    {
        name: ($props | where name == FN | get 0.value)
        email: ($props | where name == EMAIL | get value)
    }
} | to nuon
# => [[name, email]; ["Alice Example", ["[email protected]", "[email protected]"]], ["Bob Example", ["[email protected]"]]]

into datetime --format '%Y%m%dT%H%M%S' turns a date such as 20261120T120000 into a datetime. The result is in your local time zone, whatever TZID parameter the property has.

Empty input gives an empty list. Text that isn't iCalendar or vCard data doesn't stop the command. The list holds an error in place of a record, so 'hello' | from ics | length returns 1. The error appears when you use that item, for example when the list is displayed:

'hello' | from ics
# => Error: nu::shell::unsupported_input
# =>
# =>   × Unsupported input
# =>    ╭─[source:1:1]
# =>  1 │ 'hello' | from ics
# =>    · ───┬───   ────┬───
# =>    ·    │          ╰── input cannot be parsed as .ics (property error: Line 1: Missing property name.)
# =>    ·    ╰── value originates from here
# =>    ╰────

INI files

from ini returns a record with an entry for each section, which holds that section's keys and values. Keys above the first section header go in a section named with the empty string, which you can read with get '':

let config = '; global settings
name = demo

[server]
port = 8080
host = "localhost"'
$config | from ini | to nuon
# => {"": {name: demo}, server: {port: "8080", host: localhost}}

A key and its value can be separated by = or :. Lines that start with ; or # are comments, but a ; later in a line is part of the value, so port = 8080 ; the default gives "8080 ; the default". A section with no keys becomes an empty record.

The flags turn parts of the parsing off or on:

  • Quotes around a value are removed. --no-quote (-q) keeps them.
  • Backslash escapes in values, such as \t and \n, become a tab and a newline. That breaks Windows paths. C:\temp\new turns into C:, a tab, emp, a newline, and ew. --no-escape (-e) keeps backslashes as they are.
  • --indented-multiline-value (-m) reads an indented line as more of the previous value, joined with a newline. Without it, an indented line runs into the next key's name. The lines text = line one, line two, and next = 3 give a key named "line two\nnext" with the value "3".
  • Leading spaces in key names are trimmed unless you pass --preserve-key-leading-whitespace (-w). If you also pass -m, an indented line is still read as part of the previous value, not as a key.
'[paths]
temp = C:\temp\new' | from ini --no-escape | get paths.temp
# => C:\temp\new

A line with no = or : is an error:

"[server]\nport" | from ini
# => Error: nu::shell::unsupported_input
# =>
# =>   × Unsupported input
# =>    ╭─[source:1:1]
# =>  1 │ "[server]\nport" | from ini
# =>    · ────────┬───────   ────┬───
# =>    ·         │              ╰── Could not load ini: 2:5 expecting "[Some('='), Some(':')]" but found EOF.
# =>    ·         ╰── value originates from here
# =>    ╰────

Property lists

from plist reads XML, binary, and old-style text (OpenStep) property lists, from a string or from binary data. Any other input, or data that isn't a property list, fails with "Could not load plist". Because binary input works, open can read the binary .plist files that macOS keeps in ~/Library/Preferences. to plist writes an XML property list as text, or a binary one with --binary (-b).

Property list typeNushell type
dictrecord
arraylist
stringstring
integerint (one too large for an int fails)
realfloat
true, falsebool
datedatetime, in UTC
databinary
UIDfloat

to plist goes the other way. It also takes a filesize, which it writes as an integer number of bytes, and it writes datetimes in UTC. A round trip changes both:

{name: demo, size: 2kB, saved: 2026-11-14T12:30:00-06:00} | to plist | from plist | to nuon
# => {name: demo, size: 2000, saved: 2026-11-14T18:30:00+00:00}

A value with no property list type, such as null, a duration, or a range, fails the whole conversion with "Cannot convert plist", wherever it is in the input.

save settings.plist writes an XML property list. To write a binary one, use to plist --binary | save --raw settings.plist. Without --raw, save runs to plist again on the binary data, and the file ends up as an XML property list holding one data element.

The gstat plugin

gstat sums up the status of a Git repository in one record, which is handy in a prompt. It reads the repository with the libgit2 library, so it doesn't need the git command.

With no argument, gstat looks at the current directory. You can also pass a directory, or pipe one in as a string. Any directory inside a repository works, as it does with git. A path that doesn't exist or isn't a directory is an error ("path does not exist" or "path is not a directory").

gstat
# => ╭─────────────────────┬───────────────────╮
# => │ idx_added_staged    │ 1                 │
# => │ idx_modified_staged │ 0                 │
# => │ idx_deleted_staged  │ 0                 │
# => │ idx_renamed         │ 0                 │
# => │ idx_type_changed    │ 0                 │
# => │ wt_untracked        │ 1                 │
# => │ wt_modified         │ 1                 │
# => │ wt_deleted          │ 0                 │
# => │ wt_type_changed     │ 0                 │
# => │ wt_renamed          │ 0                 │
# => │ ignored             │ 1                 │
# => │ conflicts           │ 0                 │
# => │ ahead               │ 1                 │
# => │ behind              │ 0                 │
# => │ stashes             │ 0                 │
# => │ repo_name           │ repo              │
# => │ tag                 │ v0.1.0-2-g4450033 │
# => │ branch              │ main              │
# => │ remote              │ origin/main       │
# => │ state               │ clean             │
# => ╰─────────────────────┴───────────────────╯
ColumnMeaning
idx_added_staged, idx_modified_staged, idx_deleted_staged, idx_renamed, idx_type_changedFiles with staged changes of each kind
wt_untracked, wt_modified, wt_deleted, wt_type_changed, wt_renamedUnstaged changes in the working tree. A deleted file paired with a similar untracked file counts once, in wt_renamed, and not in wt_deleted or wt_untracked. A renamed file that was also edited counts in wt_modified too
ignoredIgnored files. An ignored directory counts once
conflictsFiles with unresolved merge conflicts
ahead, behindCommits ahead of and behind the upstream branch, or 0 when there's no upstream
stashesStash entries in the repository, whichever branch they were made on
repo_nameThe name of the working directory, or of the repository directory in a bare repository
tagThe nearest tag, the way git describe --tags shows it: the tag alone when HEAD is tagged, otherwise the tag, the number of commits since it, and g with the short commit hash, as in v0.1.0-2-g4450033 above. no_tag when no tag is reachable
branchThe current branch. With a detached HEAD, the first 8 hex digits of the commit. In a repository with no commits yet, the branch that HEAD names
remoteThe upstream branch, such as origin/main, or an empty string when there's none
stateThe operation in progress: clean, merge, revert, revertsequence, cherrypick, cherrypicksequence, bisect, rebase, rebaseinteractive, rebasemerge, applymailbox, or applymailboxorrebase. A git rebase stopped at a conflict shows as rebaseinteractive

Outside a repository, every count is -1, and the text columns are no_repository, no_tag, no_branch, no_remote, and no_state. In a bare repository, or when libgit2 can't read the index, the status counts are -1 and the other columns are filled in.

To find the tag, gstat walks back through the history from HEAD to the nearest tagged commit. In a large repository with no recent tag, that takes time on every call. --no-tag skips the search and reports no_tag.

This right prompt shows the branch and the numbers of staged, modified, and untracked files, and nothing outside a repository:

$env.PROMPT_COMMAND_RIGHT = {||
    let status = gstat --no-tag
    if $status.repo_name == "no_repository" {
        ""
    } else {
        $"($status.branch) +($status.idx_added_staged) ~($status.wt_modified) ?($status.wt_untracked)"
    }
}

In the repository above, it shows main +1 ~1 ?1. The garbage collector stops gstat after 10 seconds without a call, so the prompt often has to start it again. $env.config.plugin_gc.plugins.gstat = { enabled: false } keeps it running. If gstat is still slow in a large repository, see Slow Prompt Segments.

The query plugin

The query plugin adds query json, query xml, query web for HTML, and query webpage-info. query on its own returns its help text as a string, with a list of all the query subcommands. The list includes query db, which is built into Nushell and isn't part of the plugin.

All four commands take text. Read a file with open --raw, because a plain open parses a .json or .xml file into structured data, and structured input is an error:

{name: demo} | query json name
# => Error: nu::shell::error
# =>
# =>   × Problem with input data
# =>
# => Error: nu::shell::cant_convert
# =>
# =>   × Can't convert to string.
# =>    ╭─[source:1:1]
# =>  1 │ {name: demo} | query json name
# =>    · ──────┬─────
# =>    ·       ╰── can't convert record<name: string> to string
# =>    ╰────

The other commands report the same mistake as "Requires text input" (query web) or "Input type not supported" (query xml and query webpage-info). A page fetched with http get is already text.

Querying JSON

query json runs a GJSON path against JSON text. For a plain lookup, from json | get does the same job. GJSON paths add # for the length of an array or for all of its elements, #(...) for the first element that matches a condition, #(...)# for all of them, * and ? wildcards in keys, and modifiers such as @reverse after a |:

let json = '{"authors": [
    {"name": "Ann", "commits": 120, "active": true},
    {"name": "Bob", "commits": 45, "active": false},
    {"name": "Cy", "commits": 7.5, "active": true}
]}'
$json | query json 'authors.#(active==true)#.name'
# => ╭───┬─────╮
# => │ 0 │ Ann │
# => │ 1 │ Cy  │
# => ╰───┴─────╯
$json | query json 'authors.#(commits>100).name'
# => Ann
$json | query json 'authors.#.commits' | to nuon
# => [120, 45, 7.5]

The result comes back as Nushell data. Objects become records and arrays become lists. A number becomes a float if it's written with a decimal point, and an int otherwise. A path that matches nothing returns null, not an error. The @pretty and @ugly modifiers are the exception. With either one in the path, the result is JSON text, formatted or compacted:

$json | query json 'authors.0|@ugly'
# => {"name":"Ann","commits":120,"active":true}

Text that isn't JSON fails with "Invalid JSON".

Querying XML

query xml runs an XPath 1.0 expression against XML text. An expression that computes a value returns it directly: a string, a bool, or a number, which is always a float. An expression that selects nodes returns a table with a row for each node, in document order.

XPath 1.0 has no default namespace. In a document that declares one with xmlns="...", such as an Atom feed, a plain //entry matches nothing. Bind a prefix to the namespace with --namespaces (-n), a record that maps each prefix to a namespace URI string, and use the prefix in the expression. The xml prefix is always bound.

let feed = '<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <entry><title>First post</title><link href="https://example.com/1"/></entry>
    <entry><title>Second post</title><link href="https://example.com/2"/></entry>
</feed>'
$feed | query xml '//entry/title' | to nuon
# => []
$feed | query xml '//a:entry/a:title' --namespaces {a: "http://www.w3.org/2005/Atom"}
# => ╭───┬──────────────╮
# => │ # │ string_value │
# => ├───┼──────────────┤
# => │ 0 │ First post   │
# => │ 1 │ Second post  │
# => ╰───┴──────────────╯
$feed | query xml 'count(//a:entry)' --namespaces {a: "http://www.w3.org/2005/Atom"}
# => 2.0
$feed | query xml 'string(/*/@xml:lang)'
# => en

By default each row has only string_value, the node's text. --output-type adds type, which is element, attribute, text, comment, processing_instruction, root, or namespace. --output-names adds local_name, namespace, and prefixed_name, which are null for a node without a name, such as text. Once you pass any of the --output-* switches, only the columns you ask for appear. Add --output-string-value to keep the text, which this example leaves out:

$feed | query xml '//a:entry[1]/* | //a:entry[1]/a:link/@href' --namespaces {a: "http://www.w3.org/2005/Atom"} --output-type --output-names
# => ╭───┬───────────┬────────────┬─────────────────────────────┬───────────────╮
# => │ # │   type    │ local_name │          namespace          │ prefixed_name │
# => ├───┼───────────┼────────────┼─────────────────────────────┼───────────────┤
# => │ 0 │ element   │ title      │ http://www.w3.org/2005/Atom │ title         │
# => │ 1 │ element   │ link       │ http://www.w3.org/2005/Atom │ link          │
# => │ 2 │ attribute │ href       │                             │ href          │
# => ╰───┴───────────┴────────────┴─────────────────────────────┴───────────────╯

XML that doesn't parse fails with "Invalid XML document", and an XPath expression that doesn't parse fails with "invalid xpath query". To work with the whole document as Nushell data instead, use from xml.

Scraping HTML

query web picks elements out of HTML text with a CSS selector, given with --query (-q). The HTML usually comes from http get. Here it's a string:

let page = '<h1>Release <em>notes</em></h1>
<ul>
    <li><a href="/v2.html" title="Latest">Version 2</a></li>
    <li><a href="/v1.html">Version 1</a></li>
</ul>
<table>
    <tr><th>Version</th><th>Date</th><th>Notes</th></tr>
    <tr><td>2.0</td><td>2026-11-01</td><td>New parser</td></tr>
    <tr><td>1.0</td><td>2026-06-15</td></tr>
</table>'
$page | query web --query h1 | to nuon
# => [["Release ", notes]]
$page | query web --query h1 | each { str join }
# => ╭───┬───────────────╮
# => │ 0 │ Release notes │
# => ╰───┴───────────────╯
$page | query web --query 'li a' --attribute href | to nuon
# => ["/v2.html", "/v1.html"]
$page | query web --query 'li a' --attribute [href title]
# => ╭───┬──────────┬────────╮
# => │ # │   href   │ title  │
# => ├───┼──────────┼────────┤
# => │ 0 │ /v2.html │ Latest │
# => │ 1 │ /v1.html │        │
# => ╰───┴──────────┴────────╯

Each match gives a list of the pieces of text inside it, so a heading with an em element in it comes back as two strings, and str join puts them back together. --as-html (-m) returns each match's HTML instead. --attribute (-a) returns the value of one attribute, or an empty string for an element that doesn't have it. Given a list of names, --attribute returns a table with a column for each. An empty string or an empty list counts as no --attribute at all, and any other kind of value gives an empty string for each match. --attribute takes precedence over --as-html, and --as-table takes precedence over both. Without --query or --as-table, the selector is empty, which is an error:

'<p>hi</p>' | query web
# => Error: nu::shell::error
# =>
# =>   × CSS query parse error
# =>    ╭─[source:1:15]
# =>  1 │ '<p>hi</p>' | query web
# =>    ·               ────┬────
# =>    ·                   ╰─┤ Unexpected error occurred. Please report this to the developer
# =>    ·                     │ EmptySelector
# =>    ╰────
# =>   help: cannot parse query as a valid CSS selector

query web parses its input as an HTML fragment, which drops the head and body tags but keeps what's inside them. A selector that names one of them, such as body > p, matches nothing unless you add --document (-d) to parse the input as a full document:

'<html><body><p>hi</p></body></html>' | query web --query 'body > p' | to nuon
# => []
'<html><body><p>hi</p></body></html>' | query web --document --query 'body > p' | to nuon
# => [[hi]]

--as-table (-t) turns an HTML table element into a Nushell table. Give it the names of the columns you want, and it finds the tables whose first row has th cells with those names, with or without --document:

$page | query web --as-table [Version Notes]
# => ╭───┬─────────┬─────────────────────────╮
# => │ # │ Version │          Notes          │
# => ├───┼─────────┼─────────────────────────┤
# => │ 0 │ 2.0     │ New parser              │
# => │ 1 │ 1.0     │ Missing column: 'Notes' │
# => ╰───┴─────────┴─────────────────────────╯
$page | query web --as-table [Price]
# => ╭───────┬─────────────────────────────────────────────────────╮
# => │ Price │ error: no data found (column name may be incorrect) │
# => ╰───────┴─────────────────────────────────────────────────────╯

The names are case-sensitive and must match the header text exactly, but you can ask for any of the columns, in any order. Cells come back as strings with their markup removed, and a row with too few cells gets Missing column: 'NAME'. When more than one table matches, the result is a list of tables. When none does, the result is a record like the one above, not an error.

--as-table [] returns every table on the page: the table itself when there's only one, and a list of tables when there are more. The columns of each come in no fixed order. A table with no th cells in its first row gets columns named column0, column1, and so on.

--inspect (-i) helps you find the header names. With --as-table, it prints to stderr the names you passed, the first 2047 bytes of the HTML, the header row of every table on the page, and the tables that matched. With --query, --inspect ignores the selector and returns the text of the whole page.

Page metadata

query webpage-info collects a page's metadata into a record:

let page = '<html lang="en">
<head>
    <title>Release notes</title>
    <meta name="description" content="What changed in each release">
    <meta property="og:title" content="Release notes">
    <link rel="alternate" type="application/rss+xml" href="/feed.xml">
</head>
<body><p>See <a href="/v2.html">version 2</a>.</p></body>
</html>'
$page | query webpage-info | reject text_content
# => ╭─────────────┬──────────────────────────────╮
# => │ title       │ Release notes                │
# => │ description │ What changed in each release │
# => │ url         │                              │
# => │ feed        │ /feed.xml                    │
# => │ language    │ en                           │
# => │ meta        │ {record 2 fields}            │
# => │ opengraph   │ {record 5 fields}            │
# => │ schema_org  │ [list 0 items]               │
# => │ links       │ [table 1 row]                │
# => ╰─────────────┴──────────────────────────────╯
$page | query webpage-info | get opengraph | to nuon
# => {og_type: website, properties: {title: "Release notes"}, images: [], videos: [], audios: []}
  • title and description come from the title element and the meta tag named description in head, and language from the lang attribute of html or body. Each is null when the page doesn't set it.
  • url is the page's canonical link, from link rel="canonical", or null. When it's set, the URLs in links are made absolute against it. Otherwise they stay as written, because the command sees only the HTML, not where it came from.
  • feed is the last RSS, Atom, or other feed linked with rel="alternate".
  • text_content is the text of the page body, whitespace included.
  • meta maps the property, name, or http-equiv of each meta tag in head to its content, and has a charset entry when the page declares one.
  • opengraph holds the og: properties. og_type is website when the page doesn't set og:type. properties has the other properties without their og: prefix, and images, videos, and audios are lists of records with a url and properties.
  • schema_org has a record with schema_type and value for each JSON-LD block, a script element of type application/ld+json.
  • links is a table with the url and text of each link.

The inc plugin

inc takes a single value:

  • An integer goes up by 1: 41 | inc returns 42.
  • Without a flag, a string that holds a whole number goes up by 1 and stays a string, so "41" | inc returns "42". Any other string comes back unchanged.
  • With --major (-M), --minor (-m), or --patch (-p), a string is read as a semantic version and that part goes up by 1. The parts after it reset to 0, and a pre-release or build suffix is dropped, so "1.2.3-beta" | inc --minor returns "1.3.0". A string that isn't a valid version comes back unchanged. If you pass more than one of these flags, --major wins over --minor, and --minor over --patch.
  • Any other type, including a list, is an error.

The optional cell_path argument increments the value at that path and returns the whole input, so {version: "0.1.2"} | inc version --patch returns {version: "0.1.3"}. To change a column in every row of a table, call inc from update: $table | update version { inc --patch }.

For Plugin Developers

Nu plugins are executables; Nu launches them as needed and communicates with them over stdin and stdout or local sockets. Nu plugins can use either JSON or MessagePack as their communication encoding.

Examples

Nu's main repo contains example plugins that are useful for learning how the plugin protocol works:

  • Rust
  • Python
  • Nu
  • JavaScript (Node.js)

The JavaScript example is a single file, nu_plugin_node_example.js, that speaks the JSON encoding of the protocol. Its one command, node_example, ignores its arguments and returns a 10-row table. The file hard-codes the Nushell version it works with in the NUSHELL_VERSION constant, '0.103.1' as shipped. During the handshake, the plugin exits unless that constant equals the version of nu exactly, and nu itself refuses a plugin that reports an incompatible version. Before you add the plugin, set the constant to your version, the value of (version).version. Then register the file with Node.js as the interpreter, giving --shell the full path to node:

plugin add --shell (which node | get path.0) ./nu_plugin_node_example.js
plugin use node_example
node_example 2 "3" | first 3
# => ╭───┬─────┬─────┬───────╮
# => │ # │ one │ two │ three │
# => ├───┼─────┼─────┼───────┤
# => │ 0 │   0 │   0 │     0 │
# => │ 1 │   1 │   2 │     3 │
# => │ 2 │   2 │   4 │     6 │
# => ╰───┴─────┴─────┴───────╯

The Python example, nu_plugin_python_example.py, and the Nu example, nu_plugin_nu_example.nu, work the same way. They speak JSON, and each returns a 10-row table like the one above, after printing the call it received to stderr. They also hard-code NUSHELL_VERSION, and exit during the handshake unless it equals the version of nu exactly. Nu's own rule only needs the same minor version, so when the constant differs from your version only in the patch number, plugin add doesn't report a version mismatch. It fails with "Failed to receive response to plugin call from nu_example" (or python_example). Set the constant first.

Neither example needs --shell when python and nu are in your PATH, because Nu picks the interpreter from the extension, as Registering Plugins describes. For the Nu example, that's the first nu in your PATH, which may not be the one you're running. If your Python is only installed as python3, pass its path with --shell. The Python example's command is nu-python, from a plugin named python_example. The Nu example's command is nu_plugin_nu_example, from a plugin named nu_example:

plugin add ./nu_plugin_nu_example.nu
plugin use nu_example
nu_plugin_nu_example 1 a

Debugging

The simplest way to debug a plugin is to print to stderr. A plugin inherits its standard error from the nu process that started it, so what it prints there shows up in your terminal.

Tracing

To see the protocol messages that Nu and a plugin exchange, start nu with --log-level trace. Nu then logs every message it sends to or receives from a plugin, decoded from JSON or MessagePack. --log-include nu_plugin_engine::interface leaves out the rest of the trace output:

nu --log-level trace --log-include nu_plugin_engine::interface -c '1 | inc'
# => 2026-11-15 01:54:22.624 PM [TRACE] nu_plugin_engine::interface: [crates/nu-plugin-engine/src/interface/mod.rs:1163] to plugin: Hello(ProtocolInfo { protocol: NuPlugin, version: "0.117.0", features: [LocalSocket] })
# => 2026-11-15 01:54:22.624 PM [TRACE] nu_plugin_engine::interface: [crates/nu-plugin-engine/src/interface/mod.rs:468] from plugin: Hello(ProtocolInfo { protocol: NuPlugin, version: "0.117.0", features: [LocalSocket] })
# => 2026-11-15 01:54:22.630 PM [TRACE] nu_plugin_engine::interface: [crates/nu-plugin-engine/src/interface/mod.rs:1163] to plugin: Hello(ProtocolInfo { protocol: NuPlugin, version: "0.117.0", features: [LocalSocket] })
# => 2026-11-15 01:54:22.630 PM [TRACE] nu_plugin_engine::interface: [crates/nu-plugin-engine/src/interface/mod.rs:468] from plugin: Hello(ProtocolInfo { protocol: NuPlugin, version: "0.117.0", features: [LocalSocket] })
# => 2026-11-15 01:54:22.630 PM [TRACE] nu_plugin_engine::interface: [crates/nu-plugin-engine/src/interface/mod.rs:1163] to plugin: Goodbye
# => 2026-11-15 01:54:22.630 PM [TRACE] nu_plugin_engine::interface: [crates/nu-plugin-engine/src/interface/mod.rs:1163] to plugin: Call(0, Run(CallInfo { name: "inc", call: EvaluatedCall { head: Span[152671..152674], positional: [], named: [] }, input: Value(Int(1), None) }))
# => 2026-11-15 01:54:22.631 PM [TRACE] nu_plugin_engine::interface: [crates/nu-plugin-engine/src/interface/mod.rs:468] from plugin: CallResponse(0, PipelineData(Value(Int(2), None)))
# => 2

The log goes to stderr. Add --log-target file --log-file <path> to write it to a file instead, which is easier to read when you trace an interactive session. The two Hello exchanges are there because Nu starts the plugin over stdio first and then again over a local socket, since the plugin supports one.

The log shows Nu's view of each message. To capture the bytes on the wire, use trace_nu_plugin, a separate program that sits between Nu and the plugin. Install it with Cargo, then add the plugin again with the tracer as its --shell, giving the full path of both:

cargo install --locked trace_nu_plugin
plugin add --shell ~/.cargo/bin/trace_nu_plugin ~/.cargo/bin/nu_plugin_inc
plugin use inc

The new registry entry replaces the old one, because the plugin's name is the same. Nu now starts the tracer with the plugin's path and arguments. The tracer starts the plugin, passes the messages through, and appends a copy of each direction to a file in your home directory, named after the plugin's executable: nu_plugin_inc.in.raw gets what Nu sends, and nu_plugin_inc.out.raw gets what the plugin sends back. The tracer refuses to run in local socket mode, so Nu falls back to stdio.

The files hold the messages in the plugin's encoding. .out.raw starts with a length byte and the encoding name, json or msgpack. A JSON plugin gives text you can read. Of the plugins that ship with Nu, inc and query use JSON, while polars, gstat, and formats use MessagePack, which is binary. For a MessagePack plugin, the --log-level trace output is easier to read.

Warning

Trace output will accumulate for as long as the plugin is installed with the trace wrapper. Large files are possible. Be sure to remove the plugin with plugin rm when finished tracing, and reinstall without the trace wrapper.

Developer Help

Nu's plugin documentation is a work in progress. If you're unsure about something, the #plugins channel on the Nu Discord is a great place to ask questions!

More details

The plugin chapter in the contributor book offers more details on the intricacies of how plugins work from a software developer point of view.

Edit this page on GitHub
Contributors: Carson Black, Ibraheem Ahmed, nalpine, John Smith, JT, Reilly Wood, Justin Ma, WindSoilder, Hugo Sena Ribeiro, TornaxO7, Michael, Hofer-Julian, stormasm, petrisch, Devyn Cairns, jweckman, Simon Guest, fdncred, NotTheDr01ds, allan2, Martina Oefelein, Stefan Holderbach, Peng Lu
Prev
Parallelism
Next
explore