2022-02-14 02:22:51 +00:00
|
|
|
---
|
|
|
|
title: source
|
|
|
|
layout: command
|
2022-03-04 12:10:09 +00:00
|
|
|
version: 0.59.1
|
2022-02-14 02:22:51 +00:00
|
|
|
---
|
|
|
|
|
2021-05-30 00:57:04 +00:00
|
|
|
Runs a script file in the current context.
|
|
|
|
|
2022-02-14 02:22:51 +00:00
|
|
|
## Signature
|
|
|
|
|
|
|
|
```> source (filename)```
|
2021-05-30 00:57:04 +00:00
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
2022-02-14 02:22:51 +00:00
|
|
|
- `filename`: the filepath to the script file to source
|
2021-05-30 00:57:04 +00:00
|
|
|
|
2022-02-21 17:26:00 +00:00
|
|
|
## Examples
|
|
|
|
|
|
|
|
Runs foo.nu in the current context
|
|
|
|
```shell
|
|
|
|
> source foo.nu
|
|
|
|
```
|
|
|
|
|
|
|
|
Runs foo.nu in current context and call the command defined, suppose foo.nu has content: `def say-hi [] { echo 'Hi!' }`
|
|
|
|
```shell
|
|
|
|
> 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!' }`
|
|
|
|
```shell
|
|
|
|
> source ./foo.nu
|
|
|
|
```
|