Skip to content

Commit 63259ce

Browse files
Move book/commands to commands/commands (#785)
* Move `book/commands` to `commands/commands` * Move `commands/commands` to `commands/docs` * Address review comments --------- Co-authored-by: Justin Ma <[email protected]>
1 parent 10f2789 commit 63259ce

File tree

546 files changed

+454
-444
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

546 files changed

+454
-444
lines changed

.prettierignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ operators.md
66
dataframes.md
77
nushell_map.md
88
*_bash*.md
9-
book/commands/*.md
9+
commands/docs/*.md
1010
.vuepress/.temp
1111
.vuepress/.cache
1212
.vuepress/dist/

.vuepress/configs/sidebar/en.ts

+28-28
Original file line numberDiff line numberDiff line change
@@ -104,34 +104,34 @@ export const sidebarEn: SidebarConfig = {
104104
text: 'Commands',
105105
collapsible: false,
106106
children: [
107-
'bits.md',
108-
'bytes.md',
109-
'conversions.md',
110-
'core.md',
111-
'database.md',
112-
'dataframe.md',
113-
'date.md',
114-
'default.md',
115-
'deprecated.md',
116-
'env.md',
117-
'experimental.md',
118-
'expression.md',
119-
'filesystem.md',
120-
'filters.md',
121-
'formats.md',
122-
'generators.md',
123-
'hash.md',
124-
'lazyframe.md',
125-
'math.md',
126-
'misc.md',
127-
'network.md',
128-
'platform.md',
129-
'prompt.md',
130-
'random.md',
131-
'shells.md',
132-
'strings.md',
133-
'system.md',
134-
'viewers.md',
107+
'/commands/categories/bits.md',
108+
'/commands/categories/bytes.md',
109+
'/commands/categories/conversions.md',
110+
'/commands/categories/core.md',
111+
'/commands/categories/database.md',
112+
'/commands/categories/dataframe.md',
113+
'/commands/categories/date.md',
114+
'/commands/categories/default.md',
115+
'/commands/categories/deprecated.md',
116+
'/commands/categories/env.md',
117+
'/commands/categories/experimental.md',
118+
'/commands/categories/expression.md',
119+
'/commands/categories/filesystem.md',
120+
'/commands/categories/filters.md',
121+
'/commands/categories/formats.md',
122+
'/commands/categories/generators.md',
123+
'/commands/categories/hash.md',
124+
'/commands/categories/lazyframe.md',
125+
'/commands/categories/math.md',
126+
'/commands/categories/misc.md',
127+
'/commands/categories/network.md',
128+
'/commands/categories/platform.md',
129+
'/commands/categories/prompt.md',
130+
'/commands/categories/random.md',
131+
'/commands/categories/shells.md',
132+
'/commands/categories/strings.md',
133+
'/commands/categories/system.md',
134+
'/commands/categories/viewers.md',
135135
],
136136
},
137137
],

book/coloring_and_theming.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ Coloring of the prompt is controlled by the `block` in `PROMPT_COMMAND` where yo
392392
393393
## `LS_COLORS` colors for the `ls` command
394394
395-
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/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.
395+
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.
396396
397397
There's an exhaustive list [here](https://github.com/trapd00r/LS_COLORS), which is overkill, but gives you an rudimentary understanding of how to create a ls_colors file that `dircolors` can turn into a `LS_COLORS` environment variable.
398398

book/configuration.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ By convention, this variable is defined in the `config.nu` file.
3434

3535
### Environment
3636

37-
You can set environment variables for the duration of a Nushell session using [`let-env`](commands/let-env.html) calls inside the `env.nu` file. For example:
37+
You can set environment variables for the duration of a Nushell session using [`let-env`](/commands/docs/let-env.html) calls inside the `env.nu` file. For example:
3838

3939
```
4040
let-env FOO = 'BAR'
@@ -77,7 +77,7 @@ You can build the full set of environment variables by running Nu inside of anot
7777
> env | each { |it| echo $"let-env ($it.name) = '($it.raw)'" } | str join (char nl)
7878
```
7979

80-
This will print out [`let-env`](commands/let-env.html) lines, one for each environment variable along with its setting.
80+
This will print out [`let-env`](/commands/docs/let-env.html) lines, one for each environment variable along with its setting.
8181

8282
Next, on some distros you'll also need to ensure Nu is in the /etc/shells list:
8383

@@ -106,7 +106,7 @@ There is an environment variable `$nu.loginshell-path` containing the path to th
106106
### macOS: Keeping `/usr/bin/open` as `open`
107107

108108
Some tools (e.g. Emacs) rely on an `open` command to open files on Mac.
109-
As Nushell has its own [`open`](commands/open.md) command which has different semantics and shadows `/usr/bin/open`, these tools will error out when trying to use it.
109+
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.
110110
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:
111111

112112
```
@@ -116,13 +116,13 @@ alias open = ^open
116116

117117
## PATH configuration
118118

119-
In Nushell, [the PATH environment variable](<https://en.wikipedia.org/wiki/PATH_(variable)>) (Path on Windows) is a list of paths. To append a new path to it, you can use [`let-env`](commands/let-env.html) and [`append`](commands/append.html) in `env.nu`:
119+
In Nushell, [the PATH environment variable](<https://en.wikipedia.org/wiki/PATH_(variable)>) (Path on Windows) is a list of paths. To append a new path to it, you can use [`let-env`](/commands/docs/let-env.html) and [`append`](/commands/docs/append.html) in `env.nu`:
120120

121121
```
122122
let-env PATH = ($env.PATH | split row (char esep) | append '/some/path')
123123
```
124124

125-
This will append `/some/path` to the end of PATH; you can also use [`prepend`](commands/prepend.html) to add entries to the start of PATH.
125+
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.
126126

127127
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.
128128

book/custom_commands.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ Rest parameters can be used together with positional parameters:
318318

319319
```
320320
def greet [vip: string, ...name: string] {
321-
$"hello to our VIP ($vip)"
321+
$"hello to our VIP ($vip)"
322322
"and hello to everybody else:"
323323
for $n in $name {
324324
$n
@@ -399,13 +399,13 @@ Custom commands stream their output just like built-in commands. For example, le
399399
> ls | get name
400400
```
401401

402-
Let's move [`ls`](commands/ls.md) into a command that we've written:
402+
Let's move [`ls`](/commands/docs/ls.md) into a command that we've written:
403403

404404
```nushell
405405
def my-ls [] { ls }
406406
```
407407

408-
We can use the output from this command just as we would [`ls`](commands/ls.md).
408+
We can use the output from this command just as we would [`ls`](/commands/docs/ls.md).
409409

410410
```
411411
> my-ls | get name

book/dataframes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ We can have a look at the first lines of the file using `first`:
9393
### Loading the file
9494

9595
Let's start by comparing loading times between the various methods. First, we
96-
will load the data using Nushell's [`open`](commands/open.md) command:
96+
will load the data using Nushell's [`open`](/commands/docs/open.md) command:
9797

9898
```shell
9999
> benchmark {open .\Data7602DescendingYearOrder.csv}

book/environment.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
A common task in a shell is to control the environment that external applications will use. This is often done automatically, as the environment is packaged up and given to the external application as it launches. Sometimes, though, we want to have more precise control over what environment variables an application sees.
44

5-
You can see the current environment variables using the [`env`](commands/env.html) command:
5+
You can see the current environment variables using the [`env`](/commands/docs/env.html) command:
66

77
```
88
# name type value raw
@@ -25,7 +25,7 @@ The environment is initially created from the Nu [configuration file](configurat
2525

2626
There are several ways to set an environment variable:
2727

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

3030
Using the `let-env` command is the most straightforward method
3131

@@ -44,7 +44,7 @@ let-env Path = ($env.Path | prepend 'C:\path\you\want\to\add')
4444
Here we've prepended our folder to the existing folders in the Path, so it will have the highest priority.
4545
If you want to give it the lowest priority instead, you can use the `append` command.
4646

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

4949
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:
5050

@@ -57,7 +57,7 @@ If you have more than one environment variable you'd like to set, you can use `l
5757
These are defined to be active only temporarily for a duration of executing a code block.
5858
See [Single-use environment variables](environment.md#single-use-environment-variables) for details.
5959

60-
### Calling a command defined with [`def-env`](commands/def-env.md)
60+
### Calling a command defined with [`def-env`](/commands/docs/def-env.md)
6161

6262
See [Defining environment from custom commands](environment.md#defining-environment-from-custom-commands) for details.
6363

@@ -93,7 +93,7 @@ true
9393

9494
## Changing directory
9595

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

@@ -106,14 +106,14 @@ A common shorthand to set an environment variable once is available, inspired by
106106
BAR
107107
```
108108

109-
You can also use [`with-env`](commands/with-env.html) to do the same thing more explicitly:
109+
You can also use [`with-env`](/commands/docs/with-env.html) to do the same thing more explicitly:
110110

111111
```
112112
> with-env { FOO: BAR } { $env.FOO }
113113
BAR
114114
```
115115

116-
The [`with-env`](commands/with-env.html) command will temporarily set the environment variable to the value given (here: the variable "FOO" is given the value "BAR"). Once this is done, the [block](types_of_data.html#blocks) will run with this new environment variable set.
116+
The [`with-env`](/commands/docs/with-env.html) command will temporarily set the environment variable to the value given (here: the variable "FOO" is given the value "BAR"). Once this is done, the [block](types_of_data.html#blocks) will run with this new environment variable set.
117117

118118
## Permanent environment variables
119119

@@ -129,7 +129,7 @@ let-env FOO = 'BAR'
129129
## Defining environment from custom commands
130130

131131
Due to the scoping rules, any environment variables defined inside a custom command will only exist inside the command's scope.
132-
However, a command defined as [`def-env`](commands/def-env.html) instead of [`def`](commands/def.html) (it applies also to `export def`, see [Modules](modules.md)) will preserve the environment on the caller's side:
132+
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:
133133

134134
```
135135
> def-env foo [] {
@@ -192,15 +192,15 @@ Because `nu` is an external program, Nushell translated the `[ a b c ]` list acc
192192
Running commands with `nu -c` does not load the config file, therefore the env conversion for `FOO` is missing and it is displayed as a plain string -- this way we can verify the translation was successful.
193193
You can also run this step manually by `do $env.ENV_CONVERSIONS.FOO.to_string [a b c]`
194194

195-
If we look back at the [`env`](commands/env.html) command, the `raw` column shows the value translated by `ENV_CONVERSIONS.<name>.to_string` and the `value` column shows the value used in Nushell (the result of `ENV_CONVERSIONS.<name>.from_string` in the case of `FOO`).
195+
If we look back at the [`env`](/commands/docs/env.html) command, the `raw` column shows the value translated by `ENV_CONVERSIONS.<name>.to_string` and the `value` column shows the value used in Nushell (the result of `ENV_CONVERSIONS.<name>.from_string` in the case of `FOO`).
196196
If the value is not a string and does not have `to_string` conversion, it is not passed to an external (see the `raw` column of `PROMPT_COMMAND`).
197197
One exception is `PATH` (`Path` on Windows): by default, it converts the string to a list on startup and from a list to a string when running externals if no manual conversions are specified.
198198

199199
_(Important! The environment conversion string -> value happens **after** the env.nu and config.nu are evaluated. All environment variables in env.nu and config.nu are still strings unless you set them manually to some other values.)_
200200

201201
## Removing environment variables
202202

203-
You can remove an environment variable only if it was set in the current scope via [`hide-env`](commands/hide_env.html):
203+
You can remove an environment variable only if it was set in the current scope via [`hide-env`](/commands/docs/hide_env.html):
204204

205205
```
206206
> let-env FOO = 'BAR'

book/escaping.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Escaping to the system
22

3-
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/ls.md) command).
3+
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).
44

55
Nu internal command:
66

0 commit comments

Comments
 (0)