Skip to content

Commit

Permalink
Book: add links to commands (#810)
Browse files Browse the repository at this point in the history
* Fix mispelled commands

* Book: add links to commands

* Update book/advanced.md

Co-authored-by: Stefan Holderbach <[email protected]>

---------

Co-authored-by: Mate Farkas <[email protected]>
Co-authored-by: Stefan Holderbach <[email protected]>
  • Loading branch information
3 people authored Mar 9, 2023
1 parent 9744ee4 commit ba25de7
Show file tree
Hide file tree
Showing 30 changed files with 114 additions and 114 deletions.
2 changes: 1 addition & 1 deletion book/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This metadata can be used, for example, to [create custom errors](creating_error

Thanks to Nushell's strict scoping rules, it is very easy to [iterate over collections in parallel](parallelism.md) which can help you speed up long-running scripts by just typing a few characters.

You can have an overview of `explore` command with [explore](explore.md)
You can [interactively explore data](explore.md) with the [`explore`](/commands/docs/explore.md) command.

Finally, you can extend Nushell's functionality with [plugins](plugins.md).
Almost anything can be a plugin as long as it communicates with Nushell in a protocol that Nushell understands.
2 changes: 1 addition & 1 deletion book/background_task.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Here is a setup example to make nushell "support" background task:

Then you will get some commands to schedule background tasks. (e.g: `job spawn`, `job status`, `job log`)

Cons note: It spawned a fresh nushell to execute the given command, so it doesn't inherit current scope's variables, custom commands, alias definition, except env variables which can convert value to string. Therefore, if you want to use custom commands or variables, you have to `use` or `define` them within the given block.
Cons note: It spawned a fresh nushell to execute the given command, so it doesn't inherit current scope's variables, custom commands, alias definition, except env variables which can convert value to string. Therefore, if you want to use custom commands or variables, you have to [`use`](/commands/docs/use.md) or [`def`](/commands/docs/def.md) them within the given block.

## Using nu with terminal multiplexer
You can choose and install a terminal multiplexer and use it.
Expand Down
2 changes: 1 addition & 1 deletion book/coloring_and_theming.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ config {
Coloring of the prompt is controlled by the `block` in `PROMPT_COMMAND` where you can write your own custom prompt. We've written a slightly fancy one that has git statuses located in the [nu_scripts repo](https://github.com/nushell/nu_scripts/blob/main/prompt/oh-my.nu).
## `LS_COLORS` colors for the `ls` command
## `LS_COLORS` colors for the [`ls`](/commands/docs/ls.md) command
Nushell will respect and use the `LS_COLORS` environment variable setting on Mac, Linux, and Windows. This setting allows you to define the color of file types when you do a [`ls`](/commands/docs/ls.md). For instance, you can make directories one color, _.md markdown files another color, _.toml files yet another color, etc. There are a variety of ways to color your file types.
Expand Down
8 changes: 4 additions & 4 deletions book/command_signature.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Command signature

nu commands contains a signature section, take `str distance` as example, the signature is like this:
nu commands contains a signature section, take [`str distance`](/commands/docs/str_distance.md) as example, the signature is like this:

```
Signatures(Cell paths are supported):
Expand All @@ -11,14 +11,14 @@ The first type name before `|` describes the type of input pipeline. The command

`(Cell paths are supported)` indicates that you can provide cell paths for `str distance` to apply an operation at the given cell path(s) in a nested structure or table, and replace the column or field with the result, like: `ls | str distance 'nushell' 'name'`

Here is another one example, `str join`:
Here is another one example, [`str join`](/commands/docs/str_join.md):

```
Signatures:
list<string> | str join <string?> -> <string>
```

It says that `str join` command expect input pipeline is a list of string, and take optional `string` type argument, finally the output type is `string`.
It says that [`str join`](/commands/docs/str_join.md) command expect input pipeline is a list of string, and take optional `string` type argument, finally the output type is `string`.

Some commands don't accept or require data through the input pipeline, thus the input type will be `<nothing>`.
The same is true for the output type if the command returns `null` (e.g. `rm`).
The same is true for the output type if the command returns `null` (e.g. [`rm`](/commands/docs/rm.md)).
8 changes: 4 additions & 4 deletions book/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ These are some important variables to look at for Nushell-specific settings:

### Configurations with built-in commands

Starting with release v0.64 of Nushell, we have introduced two new commands(`config nu` and `config env`) which help you quickly edit nu configurations with your preferred text editor/IDE
Starting with release v0.64 of Nushell, we have introduced two new commands([`config nu`](/commands/docs/config_nu.md) and [`config env`](/commands/docs/config_env.md)) which help you quickly edit nu configurations with your preferred text editor/IDE

Nushell follows underneath orders to locate the editor:

Expand Down Expand Up @@ -111,9 +111,9 @@ There is an environment variable `$nu.loginshell-path` containing the path to th

### macOS: Keeping `/usr/bin/open` as `open`

Some tools (e.g. Emacs) rely on an `open` command to open files on Mac.
Some tools (e.g. Emacs) rely on an [`open`](/commands/docs/open.md) command to open files on Mac.
As Nushell has its own [`open`](/commands/docs/open.md) command which has different semantics and shadows `/usr/bin/open`, these tools will error out when trying to use it.
One way to work around this is to define a custom command for Nushell's `open` and create an alias for the system's `open` in your `config.nu` file like this:
One way to work around this is to define a custom command for Nushell's [`open`](/commands/docs/open.md) and create an alias for the system's [`open`](/commands/docs/open.md) in your `config.nu` file like this:

```
def nuopen [arg, --raw (-r)] { if $raw { open -r $arg } else { open $arg } }
Expand All @@ -130,7 +130,7 @@ let-env PATH = ($env.PATH | split row (char esep) | append '/some/path')

This will append `/some/path` to the end of PATH; you can also use [`prepend`](/commands/docs/prepend.html) to add entries to the start of PATH.

Note the `split row (char esep)` step. We need to add it because in `env.nu`, the environment variables inherited from the host process are still strings. The conversion step of environment variables to Nushell values happens after reading the config files (see also the [Environment](environment.html#environment-variable-conversions) section). After that, for example in the Nushell REPL when `PATH`/`Path` is a list , you can use `append`/`prepend` directly.
Note the `split row (char esep)` step. We need to add it because in `env.nu`, the environment variables inherited from the host process are still strings. The conversion step of environment variables to Nushell values happens after reading the config files (see also the [Environment](environment.html#environment-variable-conversions) section). After that, for example in the Nushell REPL when `PATH`/`Path` is a list , you can use [`append`](/commands/docs/append.md)/[`prepend`](/commands/docs/prepend.md) directly.

### Homebrew

Expand Down
4 changes: 2 additions & 2 deletions book/creating_errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ Using the [metadata](metadata.md) information, you can create your own custom er
- The title of the error
- The label of error message, which includes both the text of the label and the span to underline

You can use the `error make` command to create your own error messages. For example, let's say you had your own command called `my-command` and you wanted to give an error back to the caller about something wrong with a parameter that was passed in.
You can use the [`error make`](/commands/docs/error_make.md) command to create your own error messages. For example, let's say you had your own command called `my-command` and you wanted to give an error back to the caller about something wrong with a parameter that was passed in.

First, you can take the span of where the argument is coming from:

```
let span = (metadata $x).span;
```

Next, you can create an error using the `error make` command. This command takes in a record that describes the error to create:
Next, you can create an error using the [`error make`](/commands/docs/error_make.md) command. This command takes in a record that describes the error to create:

```
error make {msg: "this is fishy", label: {text: "fish right here", start: $span.start, end: $span.end } }
Expand Down
8 changes: 4 additions & 4 deletions book/custom_commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ _Note: It's common practice in Nushell to separate the words of the command with

## Sub-commands

You can also define subcommands to commands using a space. For example, if we wanted to add a new subcommand to `str`, we can create it by naming our subcommand to start with "str ". For example:
You can also define subcommands to commands using a space. For example, if we wanted to add a new subcommand to [`str`](/commands/docs/str.md), we can create it by naming our subcommand to start with "str ". For example:

```nushell
def "str mycommand" [] {
"hello"
}
```

Now we can call our custom command as if it were a built-in subcommand of `str`:
Now we can call our custom command as if it were a built-in subcommand of [`str`](/commands/docs/str.md):

```
> str mycommand
Expand Down Expand Up @@ -309,7 +309,7 @@ greet earth mars jupiter venus
```

::: tip
Each line of a command has its resulting value printed out when run, as long as it isn't `null`. Hence, `"hello all:"` above will be printed out despite not being the return value. To prevent this, you can place `null` (or the `ignore` command) at the end of the pipeline, like so: `"hello all:" | null`. Also note that most file system commands, such as `save` or `cd`, always output `null`.
Each line of a command has its resulting value printed out when run, as long as it isn't `null`. Hence, `"hello all:"` above will be printed out despite not being the return value. To prevent this, you can place `null` (or the [`ignore`](/commands/docs/ignore.md) command) at the end of the pipeline, like so: `"hello all:" | null`. Also note that most file system commands, such as [`save`](/commands/docs/save.md) or [`cd`](/commands/docs/cd.md), always output `null`.
:::

We could call the above definition of the `greet` command with any number of arguments, including none at all. All of the arguments are collected into `$name` as a list.
Expand Down Expand Up @@ -373,7 +373,7 @@ def greet [
}
```

The comments that we put on the definition and its parameters then appear as descriptions inside the `help` of the command.
The comments that we put on the definition and its parameters then appear as descriptions inside the [`help`](/commands/docs/help.md) of the command.

Now, if we run `help greet`, we're given a more helpful help text:

Expand Down
4 changes: 2 additions & 2 deletions book/custom_completions.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Let's look at an example:
cat dog eel
```

In the first line, we create a custom command that will return a list of three different animals. These are the values we'd like to use in the completion. Once we've created this command, we can now use it to provide completions for other custom commands and `extern`s.
In the first line, we create a custom command that will return a list of three different animals. These are the values we'd like to use in the completion. Once we've created this command, we can now use it to provide completions for other custom commands and [`extern`](/commands/docs/extern.md)s.

In the second line, we use `string@animals`. This tells Nushell two things: the shape of the argument for type-checking and the custom completion to use if the user wants to complete values at that position.

Expand Down Expand Up @@ -43,7 +43,7 @@ In our module, we've chosen to export only the custom command `my-command` but n

This is possible because custom completion tags using `@` are locked-in as the command is first parsed.

## Custom completion and `extern`
## Custom completion and [`extern`](/commands/docs/extern.md)

A powerful combination is adding custom completions to [known `extern` commands](externs.md). These work the same way as adding a custom completion to a custom command: by creating the custom completion and then attaching it with a `@` to the type of one of the positional or flag arguments of the `extern`.

Expand Down
22 changes: 11 additions & 11 deletions book/dataframes.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ The dataset has 5 columns and 5,429,252 rows. We can check that by using the
───┴──────┴─────────┴─────────
```

We can have a look at the first lines of the file using `first`:
We can have a look at the first lines of the file using [`first`](/commands/docs/first.md):

```shell
> $df | first
Expand Down Expand Up @@ -332,7 +332,7 @@ that exist in `df` by using the `aggregate` command
As you can see, the aggregate function computes the sum for those columns where
a sum makes sense. If you want to filter out the text column, you can select
the columns you want by using the `select` command
the columns you want by using the [`select`](/commands/docs/select.md) command
```shell
$df | sum | select int_1 int_2 float_1 float_2
Expand Down Expand Up @@ -416,8 +416,8 @@ right dataframe
::: tip
In `Nu` when a command has multiple arguments that are expecting
multiple values we use brackets `[]` to enclose those values. In the case of
`join` we can join on multiple columns as long as they have the
same type, for example we could have done `$df | join $df_a [int_1 int_2] [int_1 int_2]`
[`dfr join`](/commands/docs/dfr_join.md) we can join on multiple columns as long as they have the
same type, for example we could have done `$df | dfr join $df_a [int_1 int_2] [int_1 int_2]`
:::
By default, the join command does an inner join, meaning that it will keep the
Expand All @@ -428,14 +428,14 @@ in order to use it for further operations.
## DataFrame group-by
One of the most powerful operations that can be performed with a DataFrame is
the `group-by`. This command will allow you to perform aggregation operations
the [`group-by`](/commands/docs/group-by.md). This command will allow you to perform aggregation operations
based on a grouping criteria. In Nushell, a `GroupBy` is a type of object that
can be stored and reused for multiple aggregations. This is quite handy, since
the creation of the grouped pairs is the most expensive operation while doing
group-by and there is no need to repeat it if you are planning to do multiple
operations with the same group condition.
To create a `GroupBy` object you only need to use the `group-by` command
To create a `GroupBy` object you only need to use the [`group-by`](/commands/docs/group-by.md) command
```shell
> let group = ($df | group-by first)
Expand Down Expand Up @@ -794,7 +794,7 @@ and this new mask can be used to filter the dataframe
```
Another operation that can be done with masks is setting or replacing a value
from a series. For example, we can change the value in the column `first` where
from a series. For example, we can change the value in the column [`first`](/commands/docs/first.md) where
the value is equal to `a`
```shell
Expand Down Expand Up @@ -836,9 +836,9 @@ extract that information
───┴───────┴───────┴─────────┴─────────┴───────┴────────┴───────┴────────
```
The command `take` is very handy, especially if we mix it with other commands.
The command [`take`](/commands/docs/take.md) is very handy, especially if we mix it with other commands.
Let's say that we want to extract all rows for the first duplicated element for
column `first`. In order to do that, we can use the command `arg-unique` as
column [`first`](/commands/docs/first.md). In order to do that, we can use the command `arg-unique` as
shown in the next example
```shell
Expand All @@ -859,7 +859,7 @@ We can use the `arg-sort` to accomplish that. In the next example we
can sort the dataframe by the column `word`
::: tip
The same result could be accomplished using the command `sort`
The same result could be accomplished using the command [`sort`](/commands/docs/sort.md)
:::
```shell
Expand Down Expand Up @@ -914,7 +914,7 @@ these operations.
The first and most common operation that we have is `value_counts`. This
command calculates a count of the unique values that exist in a Series. For
example, we can use it to count how many occurrences we have in the column
`first`
[`first`](/commands/docs/first.md)
```shell
> $df.first | value-counts
Expand Down
10 changes: 5 additions & 5 deletions book/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ There are several ways to set an environment variable:

### [`let-env`](/commands/docs/let-env.html)

Using the `let-env` command is the most straightforward method
Using the [`let-env`](/commands/docs/let-env.md) command is the most straightforward method

```
> let-env FOO = 'BAR'
Expand All @@ -42,11 +42,11 @@ let-env Path = ($env.Path | prepend 'C:\path\you\want\to\add')
```

Here we've prepended our folder to the existing folders in the Path, so it will have the highest priority.
If you want to give it the lowest priority instead, you can use the `append` command.
If you want to give it the lowest priority instead, you can use the [`append`](/commands/docs/append.md) command.

### [`load-env`](/commands/docs/load-env.html)

If you have more than one environment variable you'd like to set, you can use `load-env` to create a table of name/value pairs and load multiple variables at the same time:
If you have more than one environment variable you'd like to set, you can use [`load-env`](/commands/docs/load-env.md) to create a table of name/value pairs and load multiple variables at the same time:

```
> load-env { "BOB": "FOO", "JAY": "BAR" }
Expand Down Expand Up @@ -94,7 +94,7 @@ true
## Changing directory

Common task in a shell is to change directory with the [`cd`](/commands/docs/cd.html) command.
In Nushell, calling `cd` is equivalent to setting the `PWD` environment variable.
In Nushell, calling [`cd`](/commands/docs/cd.md) is equivalent to setting the `PWD` environment variable.
Therefore, it follows the same rules as other environment variables (for example, scoping).

## Single-use environment variables
Expand Down Expand Up @@ -129,7 +129,7 @@ let-env FOO = 'BAR'
## Defining environment from custom commands

Due to the scoping rules, any environment variables defined inside a custom command will only exist inside the command's scope.
However, a command defined as [`def-env`](/commands/docs/def-env.html) instead of [`def`](/commands/docs/def.html) (it applies also to `export def`, see [Modules](modules.md)) will preserve the environment on the caller's side:
However, a command defined as [`def-env`](/commands/docs/def-env.html) instead of [`def`](/commands/docs/def.html) (it applies also to [`export def`](/commands/docs/export_def.md), see [Modules](modules.md)) will preserve the environment on the caller's side:

```
> def-env foo [] {
Expand Down
2 changes: 1 addition & 1 deletion book/escaping.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Escaping to the system

Nu provides a set of commands that you can use across different OSes ("internal" commands), and having this consistency is helpful. Sometimes, though, you want to run an external command that has the same name as an internal Nu command. To run the external `ls` or `date` command, for example, you use the caret (^) command. Escaping with the caret prefix calls the command that's in the user's PATH (e.g. `/bin/ls` instead of Nu's internal [`ls`](/commands/docs/ls.md) command).
Nu provides a set of commands that you can use across different OSes ("internal" commands), and having this consistency is helpful. Sometimes, though, you want to run an external command that has the same name as an internal Nu command. To run the external [`ls`](/commands/docs/ls.md) or [`date`](/commands/docs/date.md) command, for example, you use the caret (^) command. Escaping with the caret prefix calls the command that's in the user's PATH (e.g. `/bin/ls` instead of Nu's internal [`ls`](/commands/docs/ls.md) command).

Nu internal command:

Expand Down
Loading

0 comments on commit ba25de7

Please sign in to comment.