mirror of
https://github.com/nushell/nushell
synced 2024-12-27 21:43:09 +00:00
update config documentation (#2178)
* update config documentation * update config syntax * update config syntax * Update alias.md Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
This commit is contained in:
parent
6b4634b293
commit
5d17b72852
5 changed files with 18 additions and 18 deletions
|
@ -236,11 +236,11 @@ Here we use the variable `$it` to refer to the value being piped to the external
|
||||||
|
|
||||||
Nu has early support for configuring the shell. You can refer to the book for a list of [all supported variables](https://www.nushell.sh/book/en/configuration.html).
|
Nu has early support for configuring the shell. You can refer to the book for a list of [all supported variables](https://www.nushell.sh/book/en/configuration.html).
|
||||||
|
|
||||||
To set one of these variables, you can use `config --set`. For example:
|
To set one of these variables, you can use `config set`. For example:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
> config --set [edit_mode "vi"]
|
> config set edit_mode "vi"
|
||||||
> config --set [path $nu.path]
|
> config set path $nu.path
|
||||||
```
|
```
|
||||||
|
|
||||||
### Shells
|
### Shells
|
||||||
|
|
|
@ -41,7 +41,7 @@ impl WholeStreamCommand for SubCommand {
|
||||||
fn examples(&self) -> Vec<Example> {
|
fn examples(&self) -> Vec<Example> {
|
||||||
vec![Example {
|
vec![Example {
|
||||||
description: "Remove the startup commands",
|
description: "Remove the startup commands",
|
||||||
example: "config --remove startup",
|
example: "config remove startup",
|
||||||
result: None,
|
result: None,
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ pub async fn set_into(
|
||||||
// existing config
|
// existing config
|
||||||
let mut result = crate::data::config::read(name_span, &None)?;
|
let mut result = crate::data::config::read(name_span, &None)?;
|
||||||
|
|
||||||
// In the original code, this is set to `Some` if the `--load flag is set`
|
// In the original code, this is set to `Some` if the `load flag is set`
|
||||||
let configuration = None;
|
let configuration = None;
|
||||||
|
|
||||||
let rows: Vec<Value> = input.collect().await;
|
let rows: Vec<Value> = input.collect().await;
|
||||||
|
|
|
@ -12,7 +12,7 @@ The command expects three parameters:
|
||||||
|
|
||||||
## Flags
|
## Flags
|
||||||
|
|
||||||
* `-s`, `--save`: Save the alias to your config (see `config --path` to edit them later)
|
* `-s`, `--save`: Save the alias to your config (see `config path` to edit them later)
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ flags:
|
||||||
Aliases are most useful when they are persistent. For that, add them to your startup config:
|
Aliases are most useful when they are persistent. For that, add them to your startup config:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
> config --set [startup ["alias myecho [msg] { echo $msg }"]]
|
> config set startup ["alias myecho [msg] { echo $msg }"]
|
||||||
```
|
```
|
||||||
|
|
||||||
This is fine for the first alias, but since it overwrites the startup config, you need a different approach for additional aliases.
|
This is fine for the first alias, but since it overwrites the startup config, you need a different approach for additional aliases.
|
||||||
|
@ -62,7 +62,7 @@ This is fine for the first alias, but since it overwrites the startup config, yo
|
||||||
To add a 2nd alias:
|
To add a 2nd alias:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
> config --get startup | append "alias s [] { git status -sb }" | config --set_into startup
|
> config get startup | append "alias s [] { git status -sb }" | config set_into startup
|
||||||
```
|
```
|
||||||
|
|
||||||
This first reads the `startup` config (a table of strings), then appends another alias, then sets the `startup` config with the output of the pipeline.
|
This first reads the `startup` config (a table of strings), then appends another alias, then sets the `startup` config with the output of the pipeline.
|
||||||
|
@ -70,7 +70,7 @@ This first reads the `startup` config (a table of strings), then appends another
|
||||||
To make this process easier, you could define another alias:
|
To make this process easier, you could define another alias:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
> alias addalias [alias-string] { config --get startup | append $alias-string | config --set_into startup }
|
> alias addalias [alias-string] { config get startup | append $alias-string | config set_into startup }
|
||||||
```
|
```
|
||||||
|
|
||||||
Then use that to add more aliases:
|
Then use that to add more aliases:
|
||||||
|
|
|
@ -6,25 +6,25 @@ Syntax: `config {flags}`
|
||||||
|
|
||||||
## Flags
|
## Flags
|
||||||
|
|
||||||
--load <file path shape>
|
load <file path shape>
|
||||||
load the config from the path give
|
load the config from the path give
|
||||||
|
|
||||||
--set <any shape>
|
set <any shape>
|
||||||
set a value in the config, eg) --set [key value]
|
set a value in the config, eg) set variable value
|
||||||
|
|
||||||
--set_into <member shape>
|
set_into <member shape>
|
||||||
sets a variable from values in the pipeline
|
sets a variable from values in the pipeline
|
||||||
|
|
||||||
--get <any shape>
|
get <any shape>
|
||||||
get a value from the config
|
get a value from the config
|
||||||
|
|
||||||
--remove <any shape>
|
remove <any shape>
|
||||||
remove a value from the config
|
remove a value from the config
|
||||||
|
|
||||||
--clear
|
clear
|
||||||
clear the config
|
clear the config
|
||||||
|
|
||||||
--path
|
path
|
||||||
return the path to the config file
|
return the path to the config file
|
||||||
|
|
||||||
## Variables
|
## Variables
|
||||||
|
@ -47,7 +47,7 @@ Syntax: `config {flags}`
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
> config --set [table_mode "light"]
|
> config set table_mode "light"
|
||||||
```
|
```
|
||||||
|
|
||||||
A more detailed description on how to use this command to configure Nu shell can be found in the configuration chapter of [Nu Book](https://www.nushell.sh/book/en/configuration.html).
|
A more detailed description on how to use this command to configure Nu shell can be found in the configuration chapter of [Nu Book](https://www.nushell.sh/book/en/configuration.html).
|
||||||
|
|
Loading…
Reference in a new issue