mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +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).
|
||||
|
||||
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
|
||||
> config --set [edit_mode "vi"]
|
||||
> config --set [path $nu.path]
|
||||
> config set edit_mode "vi"
|
||||
> config set path $nu.path
|
||||
```
|
||||
|
||||
### Shells
|
||||
|
|
|
@ -41,7 +41,7 @@ impl WholeStreamCommand for SubCommand {
|
|||
fn examples(&self) -> Vec<Example> {
|
||||
vec![Example {
|
||||
description: "Remove the startup commands",
|
||||
example: "config --remove startup",
|
||||
example: "config remove startup",
|
||||
result: None,
|
||||
}]
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ pub async fn set_into(
|
|||
// existing config
|
||||
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 rows: Vec<Value> = input.collect().await;
|
||||
|
|
|
@ -12,7 +12,7 @@ The command expects three parameters:
|
|||
|
||||
## 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
|
||||
|
||||
|
@ -54,7 +54,7 @@ flags:
|
|||
Aliases are most useful when they are persistent. For that, add them to your startup config:
|
||||
|
||||
```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.
|
||||
|
@ -62,7 +62,7 @@ This is fine for the first alias, but since it overwrites the startup config, yo
|
|||
To add a 2nd alias:
|
||||
|
||||
```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.
|
||||
|
@ -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:
|
||||
|
||||
```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:
|
||||
|
|
|
@ -6,25 +6,25 @@ Syntax: `config {flags}`
|
|||
|
||||
## Flags
|
||||
|
||||
--load <file path shape>
|
||||
load <file path shape>
|
||||
load the config from the path give
|
||||
|
||||
--set <any shape>
|
||||
set a value in the config, eg) --set [key value]
|
||||
set <any shape>
|
||||
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
|
||||
|
||||
--get <any shape>
|
||||
get <any shape>
|
||||
get a value from the config
|
||||
|
||||
--remove <any shape>
|
||||
remove <any shape>
|
||||
remove a value from the config
|
||||
|
||||
--clear
|
||||
clear
|
||||
clear the config
|
||||
|
||||
--path
|
||||
path
|
||||
return the path to the config file
|
||||
|
||||
## Variables
|
||||
|
@ -47,7 +47,7 @@ Syntax: `config {flags}`
|
|||
## Examples
|
||||
|
||||
```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).
|
||||
|
|
Loading…
Reference in a new issue