source

Runs a script file in the current context.

Signature

> source (filename)

Parameters

  • filename: the filepath to the script file to source

Notes

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

Examples

Runs foo.nu in the current context

> source foo.nu

Runs foo.nu in current context and call the command defined, suppose foo.nu has content: def say-hi [] { echo 'Hi!' }

> source ./foo.nu; say-hi

Runs foo.nu in current context and call the main command automatically, suppose foo.nu has content: def main [] { echo 'Hi!' }

> source ./foo.nu