2022-02-14 03:22:51 +01:00
|
|
|
---
|
|
|
|
title: source
|
|
|
|
layout: command
|
2022-03-04 13:10:09 +01:00
|
|
|
version: 0.59.1
|
2022-02-14 03:22:51 +01:00
|
|
|
---
|
|
|
|
|
2021-05-30 02:57:04 +02:00
|
|
|
Runs a script file in the current context.
|
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
## Signature
|
|
|
|
|
|
|
|
```> source (filename)```
|
2021-05-30 02:57:04 +02:00
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
- `filename`: the filepath to the script file to source
|
2021-05-30 02:57:04 +02:00
|
|
|
|
2022-02-21 18:26:00 +01: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
|
|
|
|
```
|