Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update zh-CN book #1700

Merged
merged 3 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion zh-CN/book/3rdpartyprompts.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Nerdfonts 并不是必需的,但它们能使呈现效果更好。
3. 在`~/.config/nushell/config.nu`(或由`$nu.config-path`输出的路径)中设置`PROMPT_COMMAND`,将`M365Princess.mp.json`改为你喜欢的任何 [主题](https://ohmyposh.dev/docs/themes)。

```nu
> $env.PROMPT_COMMAND = { oh-my-posh --config ~/.poshthemes/M365Princess.omp.json }
$env.PROMPT_COMMAND = { oh-my-posh --config ~/.poshthemes/M365Princess.omp.json }
```

MacOS 用户配置步骤:
Expand Down
6 changes: 3 additions & 3 deletions zh-CN/book/aliases.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ Nushell 中的别名提供了一种简单的文本替换方式,这允许你为
例如,让我们创建一个名为 `ll` 的别名,它将展开为 `ls -l`。

```nu
> alias ll = ls -l
alias ll = ls -l
```

我们可以通过别名来调用它:

```nu
> ll
ll
```

一旦我们这样做了,就如同我们输入了 `ls -l` 一样。这也允许我们传入标志或位置参数。例如,我们现在也可以这样写:

```
> ll -a
ll -a
```

可得到与输入了`ls -l -a`一样的结果。
Expand Down
12 changes: 6 additions & 6 deletions zh-CN/book/coloring_and_theming.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Nushell 界面的许多部分都可以定制它们的颜色,所有这些都可
表的边框由`config.nu`中的`table_mode`设置来控制。下面是一个例子:

```nu
> $env.config = {
$env.config = {
table_mode: rounded
}
```
Expand Down Expand Up @@ -269,7 +269,7 @@ Nushell 界面的许多部分都可以定制它们的颜色,所有这些都可
下面是一个改变其中一些数值的小例子。

```nu
> let config = {
let config = {
color_config: {
separator: purple
leading_trailing_space_bg: "#ffffff"
Expand All @@ -294,7 +294,7 @@ Nushell 界面的许多部分都可以定制它们的颜色,所有这些都可
下面是另一个使用多种颜色语法的小例子,其中有一些注释:

```nu
> let config = {
let config = {
color_config: {
separator: "#88b719" # this sets only the foreground color like PR #486
leading_trailing_space_bg: white # this sets only the foreground color in the original style
Expand Down Expand Up @@ -348,7 +348,7 @@ Nushell 界面的许多部分都可以定制它们的颜色,所有这些都可
这里有一个小例子,说明如何对这些项目应用颜色。任何没有显示指定的都会被设置为默认的颜色。

```nu
> $env.config = {
$env.config = {
color_config: {
shape_garbage: { fg: "#FFFFFF" bg: "#FF0000" attr: b}
shape_bool: green
Expand All @@ -371,13 +371,13 @@ Nushell 的提示符可以通过这些环境变量进行配置:
例如:对于一个简单的提示,我们可以这样做。注意`PROMPT_COMMAND`需要一个`block`而其他的需要一个`string`。

```nu
> $env.PROMPT_COMMAND = { build-string (date now | format date '%m/%d/%Y %I:%M:%S%.3f') ': ' (pwd | path basename) }
$env.PROMPT_COMMAND = { build-string (date now | format date '%m/%d/%Y %I:%M:%S%.3f') ': ' (pwd | path basename) }
```

如果你不喜欢默认的`PROMPT_INDICATOR`,你可以这样改变它:

```nu
> $env.PROMPT_INDICATOR = "> "
$env.PROMPT_INDICATOR = "> "
```

提示的颜色由 `PROMPT_COMMAND` 中的 `block` 控制,在这里你可以编写自己的自定义提示。我们写了一个稍微花哨点的,有 git 状态的,位于 [nu_scripts 仓库](https://github.com/nushell/nu_scripts/blob/main/prompt/oh-my.nu)。
Expand Down
18 changes: 9 additions & 9 deletions zh-CN/book/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ $env | reject config | transpose key val | each {|r| echo $"$env.($r.key) = '($r
接下来,在一些发行版上,你还需要确保 Nu 在`/etc/shells`列表中:

```nu
> cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/dash
/bin/bash
/bin/rbash
/usr/bin/screen
/usr/bin/fish
/home/sophia/.cargo/bin/nu
cat /etc/shells
# => # /etc/shells: valid login shells
# => /bin/sh
# => /bin/dash
# => /bin/bash
# => /bin/rbash
# => /usr/bin/screen
# => /usr/bin/fish
# => /home/sophia/.cargo/bin/nu
```

这样你就可以使用`chsh`命令来将 Nu 设置为你的登录 Shell。在你注销后下次登录时,应该可以看到一个闪亮的 Nu 提示。
Expand Down
17 changes: 8 additions & 9 deletions zh-CN/book/creating_errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ def my-command [x] {
现在当传入一个值调用时,我们会看到一个错误信息返回:

```nu
> my-command 100

Error:
× this is fishy
╭─[entry #5:1:1]
1 │ my-command 100
· ─┬─
· ╰── fish right here
╰────
my-command 100
# => Error:
# => × this is fishy
# => ╭─[entry #5:1:1]
# => 1 │ my-command 100
# => · ─┬─
# => · ╰── fish right here
# => ╰────
```
30 changes: 15 additions & 15 deletions zh-CN/book/custom_commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def greet [name] {
要运行上述命令,我们可以像调用内置命令一样调用它:

```nu
> greet "world"
greet "world"
```

当我们这样做的时候,就会得到输出,如同我们使用内置命令一样:
Expand Down Expand Up @@ -62,7 +62,7 @@ def "str mycommand" [] {
现在我们可以像调用`str`的内置子命令一样调用我们的自定义命令:

```nu
> str mycommand
str mycommand
```

## 参数类型
Expand Down Expand Up @@ -137,10 +137,10 @@ def greet [name = "nushell"] {
你可以在没有参数的情况下调用这个命令,也可以指定一个值来覆盖默认值:

```
> greet
hello nushell
> greet world
hello world
greet
# => hello nushell
greet world
# => hello world
```

你也可以将默认值与[类型要求](#参数类型)相结合:
Expand Down Expand Up @@ -217,19 +217,19 @@ def greet [
你可以用以下方法调用上述内容:

```nu
> greet world --age 10
greet world --age 10
```

或者:

```nu
> greet --age 10 world
greet --age 10 world
```

或者甚至完全不使用标志:

```
> greet world
greet world
```

标志也可以指定一个缩写版本,这允许你传递一个更简单的标志,如同传递一个更容易阅读的全写标志那样。
Expand All @@ -250,7 +250,7 @@ _注意:_ 标志是以其全称命名的,所以上面的例子的命令体
现在,我们可以使用缩写标志来调用这个新的定义:

```
> greet -a 10 hello
greet -a 10 hello
```

标志也可以作为基本开关使用,这意味着它们的存在或不存在被当作定义的参数。延伸前面的例子:
Expand All @@ -272,13 +272,13 @@ def greet [
而这个定义可以通过如下方式调用:

```
> greet -a 10 --twice hello
greet -a 10 --twice hello
```

或者只是没有开关标志:

```
> greet -a 10 hello
greet -a 10 hello
```

## 剩余参数
Expand Down Expand Up @@ -380,7 +380,7 @@ Flags:
自定义命令会像内置命令一样流式输出。例如,假设我们想重构这个管道:

```nu
> ls | get name
ls | get name
```

让我们把[`ls`](/commands/docs/ls.md)移到我们编写的命令中:
Expand All @@ -392,7 +392,7 @@ def my-ls [] { ls }
我们就可以像使用[`ls`](/commands/docs/ls.md)一样使用这个命令的输出:

```nu
> my-ls | get name
my-ls | get name
───┬───────────────────────
0 │ myscript.nu
1 │ myscript2.nu
Expand All @@ -417,7 +417,7 @@ def double [] {
现在,如果我们在一个管道中调用上述命令,就可以看到它对输入的处理结果:

```
> [1 2 3] | double
[1 2 3] | double
───┬─────
0 │ 2
1 │ 4
Expand Down
8 changes: 4 additions & 4 deletions zh-CN/book/custom_completions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
我们来看一个例子:

```nu
> def animals [] { ["cat", "dog", "eel" ] }
> def my-command [animal: string@animals] { print $animal }
>| my-command
cat dog eel
def animals [] { ["cat", "dog", "eel" ] }
def my-command [animal: string@animals] { print $animal }
my-command
# => cat dog eel
```

在第一行中,我们创建了一个自定义命令,将返回三个不同动物的列表。这些是我们想在补全中使用的值。一旦我们创建了这个命令,我们就可以用它来为其他自定义命令和 `extern` 提供补全。
Expand Down
2 changes: 1 addition & 1 deletion zh-CN/book/dataframes.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ int_1,int_2,float_1,float_2,first,second,third,word
现在,要将该文件作为 DataFrame 进行读取,请使用 `dfr open` 命令,如下所示:

```nu
> let df = (dfr open test_small.csv)
let df = (dfr open test_small.csv)
```

这应该会在内存中创建一个值 `$df`,用来存放我们刚刚创建的数据。
Expand Down
Loading
Loading