docs(i18n): new Crowdin updates (#4124)

This commit is contained in:
Matan Kushner
2022-08-14 15:31:27 -04:00
committed by GitHub
parent 37f350a476
commit 47f22c82c4
149 changed files with 3427 additions and 764 deletions
+62 -7
View File
@@ -8,6 +8,52 @@ Starship 功能繁多,有时您必须在编辑 `starship.toml` 之外做更多
:::
## TransientPrompt in PowerShell
It is possible to replace the previous-printed prompt with a custom string. This is useful in cases where all the prompt information is not always needed. To enable this, run `Enable-TransientPrompt` in the shell session. To make it permanent, put this statement in your `$PROFILE`. Transience can be disabled on-the-fly with `Disable-TransientPrompt`.
By default, the left side of input gets replaced with `>`. To customize this, define a new function called `Invoke-Starship-TransientFunction`. For example, to display Starship's `character` module here, you would do
```powershell
function Invoke-Starship-TransientFunction {
&starship module character
}
Invoke-Expression (&starship init powershell)
Enable-TransientPrompt
```
## TransientPrompt and TransientRightPrompt in Cmd
Clink allows you to replace the previous-printed prompt with custom strings. This is useful in cases where all the prompt information is not always needed. To enable this, run `clink set prompt.transient <value>` where \<value\> can be one of:
- `always`: always replace the previous prompt
- `same_dir`: replace the previous prompt only if the working directory is same
- `off`: do not replace the prompt (i.e. turn off transience)
You need to do this only once. Make the following changes to your `starship.lua` to customize what gets displayed on the left and on the right:
- By default, the left side of input gets replaced with `>`. To customize this, define a new function called `starship_transient_prompt_func`. This function receives the current prompt as a string that you can utilize. For example, to display Starship's `character` module here, you would do
```lua
function starship_transient_prompt_func(prompt)
return io.popen("starship module character"
.." --keymap="..rl.getvariable('keymap')
):read("*a")
end
load(io.popen('starship init cmd'):read("*a"))()
```
- By default, the right side of input is empty. To customize this, define a new function called `starship_transient_rprompt_func`. This function receives the current prompt as a string that you can utilize. For example, to display the time at which the last command was started here, you would do
```lua
function starship_transient_rprompt_func(prompt)
return io.popen("starship module time"):read("*a")
end
load(io.popen('starship init cmd'):read("*a"))()
```
## 在 Cmd 中自定义提示符显示前和执行前的命令
Clink 提供了很灵活的 API,能在 Cmd shell 中运行预提示和执行前命令。 在 Starship 中使用这些 API 很容易。 对你的 `starship.lua` 按需做出如下修改:
@@ -32,11 +78,11 @@ end
load(io.popen('starship init cmd'):read("*a"))()
```
## 在 Bash 中自定义提示符显示前和执行前的命令
## 在 Bash 中自定义提示和预执行命令
Bash 不像多数其他的 Shell 有成体系的预执行框架。 因此,很难在 `bash` 中提供完全可自定义的 hook 机制。 然而,Starship 确实能使您有限地在提示符渲染过程中插入自己的函数执行:
Bash 并没有类似大多数其它 shell 的正式预执行/预命令框架。 因此,很难在 `bash` 中提供完全可自定义的 hook 机制。 然而,Starship 确实能使您有限地在提示符渲染过程中插入自己的函数执行:
- 若要在提示符显示之前运行自定义函数,需要定义此函数,然后将函数名赋值给 `starship_reserved_user_func`。 例如,如果想在提示符前绘制一火箭,可以这样写:
- 若要在提示符显示之前运行自定义函数,需要定义此函数,然后将函数名赋值给 `starship_reserved_user_func`。 例如,在提示符前绘制一火箭,您应该写
```bash
function blastoff(){
@@ -129,7 +175,7 @@ Invoke-Expression (&starship init powershell)
## 启用右侧提示
一些 Shell 支持右侧提示, 它与输入区渲染在同一行。 使用 `right_format` 选项来设置 Starship 的右侧提示。 所有支持 `format` 的组件也同时支持 `right_format`。 未显式在 `format``right_format` 中使用的组件,会保存在变量 `$all` 中。
一些 Shell 支持右侧提示, 它与输入区渲染在同一行。 Starship 可以设置右侧提示的内容,使用 `right_format` 选项。 所有支持 `format` 的组件也同时支持 `right_format`。 未显式在 `format``right_format` 中使用的组件,会保存在变量 `$all` 中。
注意:右侧提示和输入区显示在同一行。 如果需要在输入区的上方显示右对齐的组件,请查阅 [`fill` 组件](/config/#fill)。
@@ -185,19 +231,28 @@ continuation_prompt = "▶▶"
- `underline`
- `dimmed`
- `inverted`
- `blink`
- `hidden`
- `strikethrough`
- `bg:<color>`
- `fg:<color>`
- `<color>`
- `none`
`<color>` 可以声明颜色,会在下面解释。 `fg:<color>``<color>` 的功能暂时相同,未来可能会更改。 `inverted` 会反转背景和文字的颜色。 字符串中的单词顺序不影响显示结果。
`<color>` 是颜色说明符(下面解释`fg:<color>``<color>` 的功能暂时相同,未来可能会更改。 `inverted` 会反转背景和文字的颜色。 字符串中的单词顺序不影响显示结果。
`none` 不是 `bg:` 的一部分,则它会覆盖其他的设置:比如 `fg:red none fg:blue` 不会更改任何样式。 `bg:none` 会设置成默认背景色,因此 `fg:red bg:none``red``fg:red` 的作用相同;类似,`bg:green fg:red bg:none``fg:red``red` 的作用也相同。 未来可能会将 `none` 与其它单词一起使用视为错误。
`none` 不是 `bg:` 的一部分,则它会覆盖其他的设置:比如 `fg:red none fg:blue` 不会更改任何样式。 `bg:none` 会设置成默认背景色,因此 `fg:red bg:none``red``fg:red` 的作用相同;类似,`bg:green fg:red bg:none``fg:red``red` 的作用也相同。 未来可能会将 `none` 与其它标识符一起使用视为一种错误。
颜色可以以下任一内容定义
颜色说明符可以以下内容之一
- 任一标准的终端颜色:`black`, `red`, `green`, `blue`, `yellow`, `purple`, `cyan`, `white`。 您也可以使用前缀 `bright-` 定义浅色版本(例如 `bright-white`)。
- 一个 `#` 后跟一个六位十六进制数。 这将指定一个 [十六进制 RGB 颜色代码](https://www.w3schools.com/colors/colors_hexadecimal.asp)。
- 0-255 之间的数字。 这将指定一个 [8 位 ANSI 颜色码](https://i.stack.imgur.com/KTSQa.png)。
如果为文本/背景指定了多个颜色,字符串中最后指定的颜色将具有最高优先级。
Not every style string will be displayed correctly by every terminal. In particular, the following known quirks exist:
- Many terminals disable support for `blink` by default
- `hidden` is not supported on iTerm (https://gitlab.com/gnachman/iterm2/-/issues/4564).
- `strikethrough` is not supported by the default macOS Terminal.app
+101 -32
View File
@@ -111,9 +111,9 @@ Starship 中的大多数组件允许您为其设置显示样式。 显示样式
请注意,最终的显示样式将由您的终端模拟器控制。 例如,有的终端模拟器对于“bold”属性的文本是加亮颜色而不是加粗文字,有的颜色主题对“普通”和“明亮”两种属性的颜色使用相同的颜色值。 此外,要获得意大利体文本(一般设计为斜体),您的终端必须支持意大利体显示。
#### Conditional Format Strings
#### 条件格式设定
A conditional format string wrapped in `(` and `)` will not render if all variables inside are empty.
在格式设定里,由 `(``)` 包裹的内容是条件格式设定:若其包含的字段为空则不会渲染。
例如:
@@ -144,6 +144,18 @@ format = '''
\$'''
```
### Negative matching
Many modules have `detect_extensions`, `detect_files`, and `detect_folders` variables. These take lists of strings to match or not match. "Negative" options, those which should not be matched, are indicated with a leading "!" character. The presence of _any_ negative indicator in the directory will result in the module not being matched.
Extensions are matched against both the characters after the last dot in a filename, and the characters after the first dot in a filename. For example, `foo.bar.tar.gz` will be matched against `bar.tar.gz` and `gz` in the `detect_extensions` variable. Files whose name begins with a dot are not considered to have extensions at all.
To see how this works in practice, you could match TypeScript but not MPEG Transport Stream files thus:
```toml
detect_extensions = ["ts", "!video.ts", "!audio.ts"]
```
## 提示符
以下是关于提示符的配置项。
@@ -178,7 +190,7 @@ add_newline = false
### 默认提示符格式
如果没有提供`format`字段或者它的值是空的,将会使用默认的`format`配置来指定提示符的格式。 默认置如下:
如果没有提供`format`字段或者它的值是空的,将会使用默认的`format`配置来指定提示符的格式。 默认置如下:
```toml
format = "$all"
@@ -201,11 +213,9 @@ $git_status\
$hg_branch\
$docker_context\
$package\
$buf\
$c\
$cmake\
$cobol\
$container\
$daml\
$dart\
$deno\
@@ -228,6 +238,7 @@ $php\
$pulumi\
$purescript\
$python\
$raku\
$rlang\
$red\
$ruby\
@@ -238,6 +249,7 @@ $terraform\
$vlang\
$vagrant\
$zig\
$buf\
$nix_shell\
$conda\
$spack\
@@ -256,6 +268,7 @@ $jobs\
$battery\
$time\
$status\
$container\
$shell\
$character"""
```
@@ -479,6 +492,45 @@ The `buf` module shows the currently installed version of [Buf](https://buf.buil
symbol = "🦬 "
```
## Bun
The `bun` module shows the currently installed version of the [bun](https://bun.sh) JavaScript runtime. By default the module will be shown if any of the following conditions are met:
- 当前目录包含 `bun.lockb` 文件
- 当前目录包含 `bunfig.toml` 文件
### 配置项
| 选项 | 默认值 | 描述 |
| ------------------- | ------------------------------------ | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version )]($style)"` | 组件格式化模板。 |
| `version_format` | `"v${raw}"` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `symbol` | `"🍞 "` | A format string representing the symbol of Node.js. |
| `detect_extensions` | `[]` | Which extensions should trigger this module. |
| `detect_files` | `["bun.lockb", "bunfig.toml"]` | Which filenames should trigger this module. |
| `detect_folders` | `[]` | Which folders should trigger this module. |
| `style` | `"bold red"` | 此组件的样式。 |
| `disabled` | `false` | Disables the `bun` module. |
### Variables
| 字段 | 示例 | 描述 |
| --------- | -------- | -------------------- |
| version | `v0.1.4` | The version of `bun` |
| symbol | | `symbol`对应值 |
| style\* | | `style`对应值 |
*: This variable can only be used as a part of a style string
### 示例
```toml
# ~/.config/starship.toml
[bun]
format = "via [🍔 $version](bold green) "
```
## C
The `c` module shows some information about your C compiler. By default the module will be shown if the current directory contains a `.c` or `.h` file.
@@ -811,7 +863,7 @@ format = "via [✨ $version](bold blue) "
The `daml` module shows the currently used [Daml](https://www.digitalasset.com/developers) SDK version when you are in the root directory of your Daml project. The `sdk-version` in the `daml.yaml` file will be used, unless it's overridden by the `DAML_SDK_VERSION` environment variable. By default the module will be shown if any of the following conditions are met:
- The current directory contains a `daml.yaml` file
- 当前目录包含 `daml.yaml` 文件
### 配置项
@@ -851,7 +903,7 @@ The `dart` module shows the currently installed version of [Dart](https://dart.d
- The current directory contains a file with `.dart` extension
- The current directory contains a `.dart_tool` directory
- The current directory contains a `pubspec.yaml`, `pubspec.yml` or `pubspec.lock` file
- 当前目录包含 `pubspec.yaml``pubspec.yml` `pubspec.lock` 文件
### 配置项
@@ -1986,18 +2038,23 @@ Displays the current [Kubernetes context](https://kubernetes.io/docs/concepts/co
此组件默认被禁用。 若要启用此组件,请在配置文件中设置 `disable` 字段为 `false`
When the module is enabled it will always be active, unless any of `detect_extensions`, `detect_files` or `detect_folders` have been st in which case the module will only be active in directories that match those conditions.
:::
### 配置项
| 选项 | 默认值 | 描述 |
| ----------------- | ---------------------------------------------------- | --------------------------------------------------------------------- |
| `symbol` | `"☸ "` | A format string representing the symbol displayed before the Cluster. |
| `format` | `'[$symbol$context( \($namespace\))]($style) in '` | 组件格式化模板。 |
| `style` | `"cyan bold"` | 此组件的样式。 |
| `context_aliases` | | Table of context aliases to display. |
| `user_aliases` | | Table of user aliases to display. |
| `disabled` | `true` | Disables the `kubernetes` module. |
| 选项 | 默认值 | 描述 |
| ------------------- | ---------------------------------------------------- | --------------------------------------------------------------------- |
| `symbol` | `"☸ "` | A format string representing the symbol displayed before the Cluster. |
| `format` | `'[$symbol$context( \($namespace\))]($style) in '` | 组件格式化模板。 |
| `style` | `"cyan bold"` | 此组件的样式。 |
| `context_aliases` | | Table of context aliases to display. |
| `user_aliases` | | Table of user aliases to display. |
| `detect_extensions` | `[]` | Which extensions should trigger this module. |
| `detect_files` | `[]` | Which filenames should trigger this module. |
| `detect_folders` | `[]` | Which folders should trigger this modules. |
| `disabled` | `true` | Disables the `kubernetes` module. |
### Variables
@@ -2029,6 +2086,16 @@ disabled = false
"root/.*" = "root"
```
Only show the module in directories that contain a `k8s` file.
```toml
# ~/.config/starship.toml
[kubernetes]
disabled = false
detect_files = ['k8s']
```
#### Regex Matching
Additional to simple aliasing, `context_aliases` and `user_aliases` also supports extended matching and renaming using regular expressions.
@@ -2579,7 +2646,7 @@ By default the Pulumi version is not shown, since it takes an order of magnitude
By default the module will be shown if any of the following conditions are met:
- The current directory contains either `Pulumi.yaml` or `Pulumi.yml`
- A parent directory contains either `Pulumi.yaml` or `Pulumi.yml`
- A parent directory contains either `Pulumi.yaml` or `Pulumi.yml` unless `search_upwards` is set to `false`
### 配置项
@@ -2589,6 +2656,7 @@ By default the module will be shown if any of the following conditions are met:
| `version_format` | `"v${raw}"` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `symbol` | `" "` | A format string shown before the Pulumi stack. |
| `style` | `"bold 5"` | 此组件的样式。 |
| `search_upwards` | `true` | Enable discovery of pulumi config files in parent directories. |
| `disabled` | `false` | Disables the `pulumi` module. |
### Variables
@@ -3158,22 +3226,23 @@ The `status` module displays the exit code of the previous command. If $success_
### 配置项
| 选项 | 默认值 | 描述 |
| ----------------------- | ------------------------------------------------------------------------------------ | ------------------------------------------------------- |
| `format` | `"[$symbol$status]($style) "` | The format of the module |
| `symbol` | `"✖"` | The symbol displayed on program error |
| `success_symbol` | `""` | The symbol displayed on program success |
| `not_executable_symbol` | `"🚫"` | The symbol displayed when file isn't executable |
| `not_found_symbol` | `"🔍"` | The symbol displayed when the command can't be found |
| `sigint_symbol` | `"🧱"` | The symbol displayed on SIGINT (Ctrl + c) |
| `signal_symbol` | `"⚡"` | The symbol displayed on any signal |
| `style` | `"bold red"` | 此组件的样式。 |
| `recognize_signal_code` | `true` | Enable signal mapping from exit code |
| `map_symbol` | `false` | Enable symbols mapping from exit code |
| `pipestatus` | `false` | Enable pipestatus reporting |
| `pipestatus_separator` | `|` | |
| `pipestatus_format` | `\\[$pipestatus\\] => [$symbol$common_meaning$signal_name$maybe_int]($style)` | The format of the module when the command is a pipeline |
| `disabled` | `true` | Disables the `status` module. |
| 选项 | 默认值 | 描述 |
| --------------------------- | ------------------------------------------------------------------------------------ | --------------------------------------------------------------------- |
| `format` | `"[$symbol$status]($style) "` | The format of the module |
| `symbol` | `"✖"` | The symbol displayed on program error |
| `success_symbol` | `""` | The symbol displayed on program success |
| `not_executable_symbol` | `"🚫"` | The symbol displayed when file isn't executable |
| `not_found_symbol` | `"🔍"` | The symbol displayed when the command can't be found |
| `sigint_symbol` | `"🧱"` | The symbol displayed on SIGINT (Ctrl + c) |
| `signal_symbol` | `"⚡"` | The symbol displayed on any signal |
| `style` | `"bold red"` | 此组件的样式。 |
| `recognize_signal_code` | `true` | Enable signal mapping from exit code |
| `map_symbol` | `false` | Enable symbols mapping from exit code |
| `pipestatus` | `false` | Enable pipestatus reporting |
| `pipestatus_separator` | <code>&vert;</code> | The symbol used to separate pipestatus segments |
| `pipestatus_format` | `\\[$pipestatus\\] => [$symbol$common_meaning$signal_name$maybe_int]($style)` | The format of the module when the command is a pipeline |
| `pipestatus_segment_format` | | When specified, replaces `format` when formatting pipestatus segments |
| `disabled` | `true` | Disables the `status` module. |
### Variables
+4
View File
@@ -8,6 +8,10 @@
### 配置
```sh
starship preset bracketed-segments > ~/.config/starship.toml
```
[点击下载 TOML 文件](/presets/toml/bracketed-segments.toml)
<<< @/.vuepress/public/presets/toml/bracketed-segments.toml
+4
View File
@@ -12,6 +12,10 @@
### 配置
```sh
starship preset nerd-font-symbols > ~/.config/starship.toml
```
[点击下载 TOML 文件](/presets/toml/nerd-font-symbols.toml)
<<< @/.vuepress/public/presets/toml/nerd-font-symbols.toml
+4
View File
@@ -8,6 +8,10 @@
### 配置
```sh
starship preset no-runtime-versions > ~/.config/starship.toml
```
[点击下载 TOML 文件](/presets/toml/no-runtime-versions.toml)
<<< @/.vuepress/public/presets/toml/no-runtime-versions.toml
+4
View File
@@ -12,6 +12,10 @@
### 配置
```sh
starship preset pastel-powerline > ~/.config/starship.toml
```
[点击下载 TOML 文件](/presets/toml/pastel-powerline.toml)
<<< @/.vuepress/public/presets/toml/pastel-powerline.toml
+4
View File
@@ -8,6 +8,10 @@
### 配置
```sh
starship preset plain-text-symbols > ~/.config/starship.toml
```
[点击下载 TOML 文件](/presets/toml/plain-text-symbols.toml)
<<< @/.vuepress/public/presets/toml/plain-text-symbols.toml
+4
View File
@@ -8,6 +8,10 @@
### 配置
```sh
starship preset pure-preset > ~/.config/starship.toml
```
[点击下载 TOML 文件](/presets/toml/pure-preset.toml)
<<< @/.vuepress/public/presets/toml/pure-preset.toml