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
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

source for core

Runs a script file in the current context.

Signature

> source {flags} (filename)

Parameters

  • filename: The filepath to the script file to source (null for no-op).

Input/output types:

inputoutput
anyany

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

Sourcing null is a no-op.

> source null

Source can be used with const variables.

> const file = if $nu.is-interactive { "interactive.nu" } else { null }; source $file

Notes

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