W3cubDocs

/Nushell

use for core

Use definitions from a module, making them available in your shell.

Signature

> use {flags} (module) ...rest

Parameters

  • module: Module or module file
  • ...rest: Which members of the module to import

Input/output types:

input output
nothing nothing

Examples

Define a custom command in a module and call it

>modulespam { export deffoo [] { "foo" } };usespamfoo;foo
foo

Define a custom command that participates in the environment in a module and call it

>modulefoo { export def-envbar [] { $env.FOO_BAR="BAZ" } };usefoobar;bar;$env.FOO_BAR
BAZ

Use a plain module name to import its definitions qualified by the module name

>modulespam { export deffoo [] { "foo" };export defbar [] { "bar" } };usespam; (spamfoo) + (spambar)
foobar

Specify * to use all definitions in a module

>modulespam { export deffoo [] { "foo" };export defbar [] { "bar" } };usespam*; (foo) + (bar)
foobar

To use commands with spaces, like subcommands, surround them with quotes

>modulespam { export def'foo bar' [] { "baz" } };usespam'foo bar';foobar
baz

To use multiple definitions from a module, wrap them in a list

>modulespam { export deffoo [] { "foo" };export def'foo bar' [] { "baz" } };usespam ['foo', 'foo bar']; (foo) + (foobar)
foobaz

Notes

See help std for the standard library module. See help modules to list all available modules.

This command is a parser keyword. For details, check: https://www.nushell.sh/book/thinking_in_nu.html

Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/use.html