From 388f224f1240c53e17fcfb30096bfa658392b143 Mon Sep 17 00:00:00 2001 From: Matan Kushner Date: Sat, 2 Sep 2023 08:30:40 +0100 Subject: [PATCH] New translations README.md (Chinese Simplified) --- docs/zh-CN/config/README.md | 375 +++++++++++++++++++++--------------- 1 file changed, 220 insertions(+), 155 deletions(-) diff --git a/docs/zh-CN/config/README.md b/docs/zh-CN/config/README.md index 9807ad5d..18bf75dc 100644 --- a/docs/zh-CN/config/README.md +++ b/docs/zh-CN/config/README.md @@ -253,6 +253,7 @@ $kubernetes\ $directory\ $vcsh\ $fossil_branch\ +$fossil_metrics\ $git_branch\ $git_commit\ $git_state\ @@ -1524,6 +1525,41 @@ truncation_length = 4 truncation_symbol = '' ``` +## Fossil Metrics + +The `fossil_metrics` module will show the number of added and deleted lines in the check-out in your current directory. At least v2.14 (2021-01-20) of Fossil is required. + +### 配置项 + +| 选项 | 默认值 | 描述 | +| -------------------- | ------------------------------------------------------------ | ------------------------------------- | +| `format` | `'([+$added]($added_style) )([-$deleted]($deleted_style) )'` | 组件格式化模板。 | +| `added_style` | `'bold green'` | The style for the added count. | +| `deleted_style` | `'bold red'` | The style for the deleted count. | +| `only_nonzero_diffs` | `true` | Render status only for changed items. | +| `disabled` | `true` | Disables the `fossil_metrics` module. | + +### 变量 + +| 字段 | 示例 | 描述 | +| ----------------- | --- | ------------------------------------------- | +| added | `1` | The current number of added lines | +| deleted | `2` | The current number of deleted lines | +| added_style\* | | Mirrors the value of option `added_style` | +| deleted_style\* | | Mirrors the value of option `deleted_style` | + +*: 此变量只能作为样式字符串的一部分使用 + +### 示例 + +```toml +# ~/.config/starship.toml + +[fossil_metrics] +added_style = 'bold blue' +format = '[+$added]($added_style)/[-$deleted]($deleted_style) ' +``` + ## Google Cloud (`gcloud`) The `gcloud` module shows the current configuration for [`gcloud`](https://cloud.google.com/sdk/gcloud) CLI. This is based on the `~/.config/gcloud/active_config` file and the `~/.config/gcloud/configurations/config_{CONFIG NAME}` file and the `CLOUDSDK_CONFIG` env var. @@ -1602,7 +1638,7 @@ very-long-project-name = 'vlpn' ## Git Branch -`git_branch` 组件显示当前目录的 git 仓库的活动分支。 +The `git_branch` module shows the active branch of the repo in your current directory. ### 配置项 @@ -1616,7 +1652,7 @@ very-long-project-name = 'vlpn' | `truncation_symbol` | `'…'` | 此字段的内容用来表示分支名称被截断。 You can use `''` for no symbol. | | `only_attached` | `false` | Only show the branch name when not in a detached `HEAD` state. | | `ignore_branches` | `[]` | A list of names to avoid displaying. Useful for 'master' or 'main'. | -| `disabled` | `false` | 禁用 `git_branch` 组件。 | +| `disabled` | `false` | Disables the `git_branch` module. | ### 变量 @@ -1650,14 +1686,14 @@ The `git_commit` module shows the current commit hash and also the tag (if any) | 选项 | 默认值 | 描述 | | -------------------- | ------------------------------ | ------------------------------------------------------------------------------------ | -| `commit_hash_length` | `7` | 显示的 git 提交哈希值的长度。 | +| `commit_hash_length` | `7` | The length of the displayed git commit hash. | | `format` | `'[\($hash$tag\)]($style) '` | 组件格式化模板。 | | `style` | `'bold green'` | 此组件的样式。 | | `only_detached` | `true` | Only show git commit hash when in detached `HEAD` state | | `tag_disabled` | `true` | Disables showing tag info in `git_commit` module. | | `tag_max_candidates` | `0` | How many commits to consider for tag display. The default only allows exact matches. | | `tag_symbol` | `' 🏷 '` | Tag symbol prefixing the info shown | -| `disabled` | `false` | 禁用 `git_commit` 组件。 | +| `disabled` | `false` | Disables the `git_commit` module. | ### 变量 @@ -1681,7 +1717,7 @@ tag_symbol = '🔖 ' ## Git State -`git_state` 组件会显示当前目录在哪个 git 仓库中,以及正在进行的操作,例如:_REBASING_,_BISECTING_ 等。 进度信息(例如 REBASING 3/10)如果存在则也会被显示。 +The `git_state` module will show in directories which are part of a git repository, and where there is an operation in progress, such as: _REBASING_, _BISECTING_, etc. If there is progress information (e.g., REBASING 3/10), that information will be shown too. ### 配置项 @@ -1696,7 +1732,7 @@ tag_symbol = '🔖 ' | `am_or_rebase` | `'AM/REBASE'` | A format string displayed when an ambiguous `apply-mailbox` or `rebase` is in progress. | | `style` | `'bold yellow'` | 此组件的样式。 | | `format` | `'\([$state( $progress_current/$progress_total)]($style)\) '` | 组件格式化模板。 | -| `disabled` | `false` | 禁用 `git_state` 组件。 | +| `disabled` | `false` | Disables the `git_state` module. | ### 变量 @@ -1725,7 +1761,7 @@ The `git_metrics` module will show the number of added and deleted lines in the ::: tip -此组件默认被禁用。 若要启用此组件,请在配置文件中设置 `disable` 字段为 `false`。 +This module is disabled by default. To enable it, set `disabled` to `false` in your configuration file. ::: @@ -1738,7 +1774,7 @@ The `git_metrics` module will show the number of added and deleted lines in the | `only_nonzero_diffs` | `true` | Render status only for changed items. | | `format` | `'([+$added]($added_style) )([-$deleted]($deleted_style) )'` | 组件格式化模板。 | | `disabled` | `true` | Disables the `git_metrics` module. | -| `忽略子模块` | `false` | 忽略子模块的更改 | +| `ignore_submodules` | `false` | Ignore changes to submodules | ### 变量 @@ -1763,7 +1799,7 @@ format = '[+$added]($added_style)/[-$deleted]($deleted_style) ' ## Git Status -`git_status`组件通过相应的符号显示您当前目录中 git 仓库的状态。 +The `git_status` module shows symbols representing the state of the repo in your current directory. ::: tip @@ -1773,25 +1809,25 @@ The Git Status module is very slow in Windows directories (for example under `/m ### 配置项 -| 选项 | 默认值 | 描述 | -| ------------------ | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | -| `format` | `'([\[$all_status$ahead_behind\]]($style) )'` | The default format for `git_status` | -| `conflicted` | `'='` | 这个分支有合并冲突。 | -| `ahead` | `'⇡'` | The format of `ahead` | -| `behind` | `'⇣'` | The format of `behind` | -| `diverged` | `'⇕'` | The format of `diverged` | -| `up_to_date` | `''` | The format of `up_to_date` | -| `untracked` | `'?'` | The format of `untracked` | -| `stashed` | `'$'` | The format of `stashed` | -| `modified` | `'!'` | The format of `modified` | -| `staged` | `'+'` | The format of `staged` | -| `renamed` | `'»'` | The format of `renamed` | -| `deleted` | `'✘'` | The format of `deleted` | -| `typechanged` | `""` | The format of `typechange` | -| `style` | `'bold red'` | 此组件的样式。 | -| `忽略子模块` | `false` | 忽略子模块的更改. | -| `disabled` | `false` | 禁用 `git_status` 组件。 | -| `windows_starship` | | Use this (Linux) path to a Windows Starship executable to render `git_status` when on Windows paths in WSL. | +| 选项 | 默认值 | 描述 | +| ------------------- | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | +| `format` | `'([\[$all_status$ahead_behind\]]($style) )'` | The default format for `git_status` | +| `conflicted` | `'='` | This branch has merge conflicts. | +| `ahead` | `'⇡'` | The format of `ahead` | +| `behind` | `'⇣'` | The format of `behind` | +| `diverged` | `'⇕'` | The format of `diverged` | +| `up_to_date` | `''` | The format of `up_to_date` | +| `untracked` | `'?'` | The format of `untracked` | +| `stashed` | `'$'` | The format of `stashed` | +| `modified` | `'!'` | The format of `modified` | +| `staged` | `'+'` | The format of `staged` | +| `renamed` | `'»'` | The format of `renamed` | +| `deleted` | `'✘'` | The format of `deleted` | +| `typechanged` | `""` | The format of `typechange` | +| `style` | `'bold red'` | 此组件的样式。 | +| `ignore_submodules` | `false` | Ignore changes to submodules. | +| `disabled` | `false` | Disables the `git_status` module. | +| `windows_starship` | | Use this (Linux) path to a Windows Starship executable to render `git_status` when on Windows paths in WSL. | ### 变量 @@ -1822,9 +1858,9 @@ The following variables can be used in `diverged`: The following variables can be used in `conflicted`, `ahead`, `behind`, `untracked`, `stashed`, `modified`, `staged`, `renamed` and `deleted`: -| 字段 | 描述 | -| ------- | --------- | -| `count` | 显示相应的文件数量 | +| 字段 | 描述 | +| ------- | ------------------------ | +| `count` | Show the number of files | ### 示例 @@ -1891,7 +1927,7 @@ The `golang` module shows the currently installed version of [Go](https://golang | `detect_folders` | `['Godeps']` | Which folders should trigger this module. | | `style` | `'bold cyan'` | 此组件的样式。 | | `not_capable_style` | `'bold red'` | The style for the module when the go directive in the go.mod file does not match the installed Go version. | -| `disabled` | `false` | 禁用 `golang` 组件。 | +| `disabled` | `false` | Disables the `golang` module. | ### 变量 @@ -2008,7 +2044,7 @@ By default the module will be shown if any of the following conditions are met: | `detect_files` | `['stack.yaml', 'cabal.project']` | Which filenames should trigger this module. | | `detect_folders` | `[]` | Which folders should trigger this module. | | `style` | `'bold purple'` | 此组件的样式。 | -| `disabled` | `false` | 禁用 `haskell` 组件。 | +| `disabled` | `false` | Disables the `haskell` module. | ### 变量 @@ -2103,18 +2139,18 @@ format = 'via [⎈ $version](bold white) ' ## Hostname -`hostname` 组件显示系统主机名。 +The `hostname` module shows the system hostname. ### 配置项 -| 选项 | 默认值 | 描述 | -| ------------ | -------------------------------------- | ----------------------------------------------------------------------------------------------------- | -| `ssh_only` | `true` | 仅在连接到 SSH 会话时显示主机名。 | -| `ssh_symbol` | `'🌐 '` | A format string representing the symbol when connected to SSH session. | -| `trim_at` | `'.'` | 当主机名过长被截断时,会截断成第一次匹配该字符串之前的主机名。 `'.'` will stop after the first dot. `''` will disable any truncation | -| `format` | `'[$ssh_symbol$hostname]($style) in '` | 组件格式化模板。 | -| `style` | `'bold dimmed green'` | 此组件的样式。 | -| `disabled` | `false` | 禁用 `hostname` 组件。 | +| 选项 | 默认值 | 描述 | +| ------------ | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | +| `ssh_only` | `true` | Only show hostname when connected to an SSH session. | +| `ssh_symbol` | `'🌐 '` | A format string representing the symbol when connected to SSH session. | +| `trim_at` | `'.'` | String that the hostname is cut off at, after the first match. `'.'` will stop after the first dot. `''` will disable any truncation | +| `format` | `'[$ssh_symbol$hostname]($style) in '` | 组件格式化模板。 | +| `style` | `'bold dimmed green'` | 此组件的样式。 | +| `disabled` | `false` | Disables the `hostname` module. | ### 变量 @@ -2156,7 +2192,7 @@ The `java` module shows the currently installed version of [Java](https://www.or | `detect_folders` | `[]` | Which folders should trigger this modules. | | `符号` | `'☕ '` | A format string representing the symbol of Java | | `style` | `'red dimmed'` | 此组件的样式。 | -| `disabled` | `false` | 禁用 `java` 组件。 | +| `disabled` | `false` | Disables the `java` module. | ### 变量 @@ -2179,7 +2215,7 @@ symbol = '🌟 ' ## Jobs -`jobs` 组件显示当前正在运行的任务数量。 仅当有后台任务运行时,此组件才会显示。 The module will show the number of jobs running if there are at least 2 jobs, or more than the `number_threshold` config value, if it exists. The module will show a symbol if there is at least 1 job, or more than the `symbol_threshold` config value, if it exists. You can set both values to 0 in order to _always_ show the symbol and number of jobs, even if there are 0 jobs running. +The `jobs` module shows the current number of jobs running. The module will be shown only if there are background jobs running. The module will show the number of jobs running if there are at least 2 jobs, or more than the `number_threshold` config value, if it exists. The module will show a symbol if there is at least 1 job, or more than the `symbol_threshold` config value, if it exists. You can set both values to 0 in order to _always_ show the symbol and number of jobs, even if there are 0 jobs running. The default functionality is: @@ -2203,13 +2239,13 @@ The `threshold` option is deprecated, but if you want to use it, the module will | 选项 | 默认值 | 描述 | | ------------------ | ----------------------------- | ------------------------------------------------------------------------ | -| `threshold`* | `1` | 如果超过此字段的值,显示任务数量。 | +| `threshold`* | `1` | Show number of jobs if exceeded. | | `symbol_threshold` | `1` | Show `symbol` if the job count is at least `symbol_threshold`. | | `number_threshold` | `2` | Show the number of jobs if the job count is at least `number_threshold`. | | `format` | `'[$symbol$number]($style) '` | 组件格式化模板。 | | `符号` | `'✦'` | The string used to represent the `symbol` variable. | | `style` | `'bold blue'` | 此组件的样式。 | -| `disabled` | `false` | 禁用 `jobs` 组件。 | +| `disabled` | `false` | Disables the `jobs` module. | *: This option is deprecated, please use the `number_threshold` and `symbol_threshold` options instead. @@ -2323,11 +2359,11 @@ kotlin_binary = 'kotlinc' ## Kubernetes -Displays the current [Kubernetes context](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#context) name and, if set, the namespace, user and cluster from the kubeconfig file. The namespace needs to be set in the kubeconfig file, this can be done via `kubectl config set-context starship-context --namespace astronaut`. Similarly the user and cluster can be set with `kubectl config set-context starship-context --user starship-user` and `kubectl config set-context starship-context --cluster starship-cluster`. If the `$KUBECONFIG` env var is set the module will use that if not it will use the `~/.kube/config`. +Displays the current [Kubernetes context](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#context) name and, if set, the namespace, user and cluster from the kubeconfig file. The namespace needs to be set in the kubeconfig file, this can be done via `kubectl config set-context starship-context --namespace astronaut`. Similarly, the user and cluster can be set with `kubectl config set-context starship-context --user starship-user` and `kubectl config set-context starship-context --cluster starship-cluster`. If the `$KUBECONFIG` env var is set the module will use that if not it will use the `~/.kube/config`. ::: tip -此组件默认被禁用。 若要启用此组件,请在配置文件中设置 `disable` 字段为 `false`。 +This module is disabled by default. To enable it, set `disabled` to `false` in your configuration file. When the module is enabled it will always be active, unless any of `detect_extensions`, `detect_files` or `detect_folders` have been set in which case the module will only be active in directories that match those conditions. @@ -2335,18 +2371,40 @@ When the module is enabled it will always be active, unless any of `detect_exten ### 配置项 +::: warning + +The `context_aliases` and `user_aliases` options are deprecated. Use `contexts` and the corresponding `context_alias` and `user_alias` options instead. + +::: + | 选项 | 默认值 | 描述 | | ------------------- | ---------------------------------------------------- | --------------------------------------------------------------------- | | `符号` | `'☸ '` | 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. | +| `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. | +| `contexts` | `[]` | Customized styles and symbols for specific contexts. | | `disabled` | `true` | Disables the `kubernetes` module. | +*: This option is deprecated, please add `contexts` with the corresponding `context_alias` and `user_alias` options instead. + +To customize the style of the module for specific environments, use the following configuration as part of the `contexts` list: + +| 字段 | 描述 | +| ----------------- | ---------------------------------------------------------------------------------------- | +| `context_pattern` | **Required** Regular expression to match current Kubernetes context name. | +| `user_pattern` | Regular expression to match current Kubernetes user name. | +| `context_alias` | Context alias to display instead of the full context name. | +| `user_alias` | User alias to display instead of the full user name. | +| `style` | The style for the module when using this context. If not set, will use module's style. | +| `符号` | The symbol for the module when using this context. If not set, will use module's symbol. | + +Note that all regular expression are anchored with `^$` and so must match the whole string. The `*_pattern` regular expressions may contain capture groups, which can be referenced in the corresponding alias via `$name` and `$N` (see example below and the [rust Regex::replace() documentation](https://docs.rs/regex/latest/regex/struct.Regex.html#method.replace)). + ### 变量 | 字段 | 示例 | 描述 | @@ -2368,13 +2426,9 @@ When the module is enabled it will always be active, unless any of `detect_exten [kubernetes] format = 'on [⛵ ($user on )($cluster in )$context \($namespace\)](dimmed green) ' disabled = false -[kubernetes.context_aliases] -'dev.local.cluster.k8s' = 'dev' -'.*/openshift-cluster/.*' = 'openshift' -'gke_.*_(?P[\w-]+)' = 'gke-$var_cluster' -[kubernetes.user_aliases] -'dev.local.cluster.k8s' = 'dev' -'root/.*' = 'root' +contexts = [ + { context_pattern = "dev.local.cluster.k8s", style = "green", symbol = "💔 " }, +] ``` Only show the module in directories that contain a `k8s` file. @@ -2387,36 +2441,47 @@ disabled = false detect_files = ['k8s'] ``` -#### Regex Matching +#### Kubernetes Context specific config -Additional to simple aliasing, `context_aliases` and `user_aliases` also supports extended matching and renaming using regular expressions. - -The regular expression must match on the entire kube context, capture groups can be referenced using `$name` and `$N` in the replacement. This is more explained in the [regex crate](https://docs.rs/regex/1.5.4/regex/struct.Regex.html#method.replace) documentation. - -Long and automatically generated cluster names can be identified and shortened using regular expressions: +The `contexts` configuration option is used to customise what the current Kubernetes context name looks like (style and symbol) if the name matches the defined regular expression. ```toml -[kubernetes.context_aliases] -# OpenShift contexts carry the namespace and user in the kube context: `namespace/name/user`: -'.*/openshift-cluster/.*' = 'openshift' -# Or better, to rename every OpenShift cluster at once: -'.*/(?P[\w-]+)/.*' = '$var_cluster' +# ~/.config/starship.toml +[[kubernetes.contexts]] +# "bold red" style + default symbol when Kubernetes current context name equals "production" *and* the current user +# equals "admin_user" +context_pattern = "production" +user_pattern = "admin_user" +style = "bold red" +context_alias = "prod" +user_alias = "admin" + +[[kubernetes.contexts]] +# "green" style + a different symbol when Kubernetes current context name contains openshift +context_pattern = ".*openshift.*" +style = "green" +symbol = "💔 " +context_alias = "openshift" + +[[kubernetes.contexts]] +# Using capture groups # Contexts from GKE, AWS and other cloud providers usually carry additional information, like the region/zone. # The following entry matches on the GKE format (`gke_projectname_zone_cluster-name`) # and renames every matching kube context into a more readable format (`gke-cluster-name`): -'gke_.*_(?P[\w-]+)' = 'gke-$var_cluster' +context_pattern = "gke_.*_(?P[\\w-]+)" +context_alias = "gke-$cluster" ``` ## Line Break -`line_break` 组件将提示分隔为两行。 +The `line_break` module separates the prompt into two lines. ### 配置项 -| 选项 | 默认值 | 描述 | -| ---------- | ------- | --------------------------- | -| `disabled` | `false` | 禁用 `line_break` 组件,使提示成为单行。 | +| 选项 | 默认值 | 描述 | +| ---------- | ------- | ------------------------------------------------------------------ | +| `disabled` | `false` | Disables the `line_break` module, making the prompt a single line. | ### 示例 @@ -2503,25 +2568,25 @@ format = 'via [🌕 $version](bold blue) ' ## Memory Usage -`memory_usage` 组件显示当前系统内存和交换区使用情况。 +The `memory_usage` module shows current system memory and swap usage. -默认情况下,如果系统交换区使用不为 0,则会显示交换区使用情况。 +By default the swap usage is displayed if the total system swap is non-zero. ::: tip -此组件默认被禁用。 若要启用此组件,请在配置文件中设置 `disable` 字段为 `false`。 +This module is disabled by default. To enable it, set `disabled` to `false` in your configuration file. ::: ### 配置项 -| 选项 | 默认值 | 描述 | -| ----------- | ----------------------------------------------- | ---------------------- | -| `threshold` | `75` | 隐藏内存使用情况,除非它超过这个百分比。 | -| `format` | `'via $symbol [${ram}( \| ${swap})]($style) '` | 组件格式化模板。 | -| `符号` | `'🐏'` | 这个字段的内容会显示在当前内存使用情况之前。 | -| `style` | `'bold dimmed white'` | 此组件的样式。 | -| `disabled` | `true` | 禁用 `memory_usage` 组件。 | +| 选项 | 默认值 | 描述 | +| ----------- | ----------------------------------------------- | -------------------------------------------------------- | +| `threshold` | `75` | Hide the memory usage unless it exceeds this percentage. | +| `format` | `'via $symbol [${ram}( \| ${swap})]($style) '` | 组件格式化模板。 | +| `符号` | `'🐏'` | The symbol used before displaying the memory usage. | +| `style` | `'bold dimmed white'` | 此组件的样式。 | +| `disabled` | `true` | Disables the `memory_usage` module. | ### 变量 @@ -2593,14 +2658,14 @@ The `hg_branch` module shows the active branch and topic of the repo in your cur ### 配置项 -| 选项 | 默认值 | 描述 | -| ------------------- | ----------------------------------------- | ----------------------------------------------------- | -| `符号` | `' '` | 该字段的内容显示于当前仓库的 hg 书签或活动分支名之前。 | -| `style` | `'bold purple'` | 此组件的样式。 | -| `format` | `'on [$symbol$branch(:$topic)]($style) '` | 组件格式化模板。 | -| `truncation_length` | `2^63 - 1` | Truncates the hg branch / topic name to `N` graphemes | -| `truncation_symbol` | `'…'` | 此字段的内容用来表示分支名称被截断。 | -| `disabled` | `true` | 禁用 `hg_branch` 组件。 | +| 选项 | 默认值 | 描述 | +| ------------------- | ----------------------------------------- | -------------------------------------------------------------------------------------------- | +| `符号` | `' '` | The symbol used before the hg bookmark or branch name of the repo in your current directory. | +| `style` | `'bold purple'` | 此组件的样式。 | +| `format` | `'on [$symbol$branch(:$topic)]($style) '` | 组件格式化模板。 | +| `truncation_length` | `2^63 - 1` | Truncates the hg branch / topic name to `N` graphemes | +| `truncation_symbol` | `'…'` | 此字段的内容用来表示分支名称被截断。 | +| `disabled` | `true` | Disables the `hg_branch` module. | ### 变量 @@ -2668,7 +2733,7 @@ symbol = '🎣 ' ## Nix-shell -The `nix_shell` module shows the [nix-shell](https://nixos.org/guides/nix-pills/developing-with-nix-shell.html) environment. 当处于一个 nix-shell 环境中时,此组件会被显示。 +The `nix_shell` module shows the [nix-shell](https://nixos.org/guides/nix-pills/developing-with-nix-shell.html) environment. The module will be shown when inside a nix-shell environment. ### 配置项 @@ -2678,16 +2743,16 @@ The `nix_shell` module shows the [nix-shell](https://nixos.org/guides/nix-pills/ | `符号` | `'❄️ '` | A format string representing the symbol of nix-shell. | | `style` | `'bold blue'` | 此组件的样式。 | | `impure_msg` | `'impure'` | A format string shown when the shell is impure. | -| `pure_msg` | `'纯色'` | A format string shown when the shell is pure. | +| `pure_msg` | `'pure'` | A format string shown when the shell is pure. | | `unknown_msg` | `''` | A format string shown when it is unknown if the shell is pure/impure. | -| `disabled` | `false` | 禁用 `nix_shell` 组件。 | +| `disabled` | `false` | Disables the `nix_shell` module. | | `heuristic` | `false` | Attempts to detect new `nix shell`-style shells with a heuristic. | ### 变量 | 字段 | 示例 | 描述 | | --------- | ------- | -------------------------- | -| state | `纯色` | The state of the nix-shell | +| state | `pure` | The state of the nix-shell | | name | `lorri` | The name of the nix-shell | | 符号 | | `symbol`对应值 | | style\* | | `style`对应值 | @@ -2729,7 +2794,7 @@ The `nodejs` module shows the currently installed version of [Node.js](https://n | `detect_files` | `['package.json', '.node-version']` | Which filenames should trigger this module. | | `detect_folders` | `['node_modules']` | Which folders should trigger this module. | | `style` | `'bold green'` | 此组件的样式。 | -| `disabled` | `false` | 禁用 `nodejs` 组件。 | +| `disabled` | `false` | Disables the `nodejs` module. | | `not_capable_style` | `bold red` | The style for the module when an engines property in package.json does not match the Node.js version. | ### 变量 @@ -2882,7 +2947,7 @@ The [os_info](https://lib.rs/crates/os_info) crate used by this module is known ::: tip -此组件默认被禁用。 若要启用此组件,请在配置文件中设置 `disable` 字段为 `false`。 +This module is disabled by default. To enable it, set `disabled` to `false` in your configuration file. ::: @@ -2949,7 +3014,7 @@ Windows = "🪟 " | --------- | ------------ | ------------------------------------------------------------------ | | 符号 | `🎗️` | The current operating system symbol from advanced option `symbols` | | name | `Arch Linux` | The current operating system name | -| 类型 | `Arch` | The current operating system type | +| type | `Arch` | The current operating system type | | codename | | The current operating system codename, if applicable | | edition | | The current operating system edition, if applicable | | version | | The current operating system version, if applicable | @@ -2974,7 +3039,7 @@ Arch = "Arch is the best! " ## Package Version -当前目录是软件包的代码仓库时,将显示 `package` 组件,并显示软件包当前版本。 The module currently supports `npm`, `nimble`, `cargo`, `poetry`, `python`, `composer`, `gradle`, `julia`, `mix`, `helm`, `shards`, `daml` and `dart` packages. +The `package` module is shown when the current directory is the repository for a package, and shows its current version. The module currently supports `npm`, `nimble`, `cargo`, `poetry`, `python`, `composer`, `gradle`, `julia`, `mix`, `helm`, `shards`, `daml` and `dart` packages. - [**npm**](https://docs.npmjs.com/cli/commands/npm) – The `npm` package version is extracted from the `package.json` present in the current directory - [**Cargo**](https://doc.rust-lang.org/cargo/) – The `cargo` package version is extracted from the `Cargo.toml` present in the current directory @@ -3001,11 +3066,11 @@ Arch = "Arch is the best! " | 选项 | 默认值 | 描述 | | ----------------- | --------------------------------- | ------------------------------------------------------------------------- | | `format` | `'is [$symbol$version]($style) '` | 组件格式化模板。 | -| `符号` | `'📦 '` | 这个字段的内容会显示在当前软件包版本之前。 | +| `符号` | `'📦 '` | The symbol used before displaying the version the package. | | `version_format` | `'v${raw}'` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` | | `style` | `'bold 208'` | 此组件的样式。 | | `display_private` | `false` | Enable displaying version for packages marked as private. | -| `disabled` | `false` | 禁用 `package` 组件。 | +| `disabled` | `false` | Disables the `package` module. | ### 变量 @@ -3080,12 +3145,12 @@ The `php` module shows the currently installed version of [PHP](https://www.php. | ------------------- | ------------------------------------ | ------------------------------------------------------------------------- | | `format` | `'via [$symbol($version )]($style)'` | 组件格式化模板。 | | `version_format` | `'v${raw}'` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` | -| `符号` | `'🐘 '` | 这个字段的内容会显示在当前 PHP 版本之前。 | +| `符号` | `'🐘 '` | The symbol used before displaying the version of PHP. | | `detect_extensions` | `['php']` | Which extensions should trigger this module. | | `detect_files` | `['composer.json', '.php-version']` | Which filenames should trigger this module. | | `detect_folders` | `[]` | Which folders should trigger this module. | | `style` | `'147 bold'` | 此组件的样式。 | -| `disabled` | `false` | 禁用 `php` 组件。 | +| `disabled` | `false` | Disables the `php` module. | ### 变量 @@ -3222,7 +3287,7 @@ format = 'via [$symbol$version](bold white)' The `python` module shows the currently installed version of [Python](https://www.python.org/) and the current [Python virtual environment](https://docs.python.org/tutorial/venv.html) if one is activated. -如果`pyenv_version_name`被设置为`true`, 本组件将会展示pyenv版本名。 否则则显示通过`python --version`获得的版本号 +If `pyenv_version_name` is set to `true`, it will display the pyenv version name. Otherwise, it will display the version number from `python --version`. By default the module will be shown if any of the following conditions are met: @@ -3242,15 +3307,15 @@ By default the module will be shown if any of the following conditions are met: | -------------------- | ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- | | `format` | `'via [${symbol}${pyenv_prefix}(${version} )(\($virtualenv\) )]($style)'` | 组件格式化模板。 | | `version_format` | `'v${raw}'` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` | -| `符号` | `'🐍 '` | 用于表示Python的格式化字符串。 | +| `符号` | `'🐍 '` | A format string representing the symbol of Python | | `style` | `'yellow bold'` | 此组件的样式。 | -| `pyenv_version_name` | `false` | 使用 pyenv 获取 Python 版本 | +| `pyenv_version_name` | `false` | Use pyenv to get Python version | | `pyenv_prefix` | `pyenv` | Prefix before pyenv version display, only used if pyenv is used | | `python_binary` | `['python', 'python3', 'python2']` | Configures the python binaries that Starship should executes when getting the version. | | `detect_extensions` | `['py']` | Which extensions should trigger this module | | `detect_files` | `['.python-version', 'Pipfile', '__init__.py', 'pyproject.toml', 'requirements.txt', 'setup.py', 'tox.ini']` | Which filenames should trigger this module | | `detect_folders` | `[]` | Which folders should trigger this module | -| `disabled` | `false` | 禁用 `python` 组件。 | +| `disabled` | `false` | Disables the `python` module. | ::: tip @@ -3264,11 +3329,11 @@ The default values and order for `python_binary` was chosen to first identify th | 字段 | 示例 | 描述 | | ------------ | --------------- | ------------------------------------------ | -| version | `'v3.8.1'` | `python`版本 | +| version | `'v3.8.1'` | The version of `python` | | 符号 | `'🐍 '` | `symbol`对应值 | | style | `'yellow bold'` | `style`对应值 | | pyenv_prefix | `'pyenv '` | Mirrors the value of option `pyenv_prefix` | -| virtualenv | `'venv'` | 当前`virtualenv`名称 | +| virtualenv | `'venv'` | The current `virtualenv` name | ### 示例 @@ -3389,7 +3454,7 @@ format = 'via [🦪 $version]($style) ' ## Red -By default the `red` module shows the currently installed version of [Red](https://www.red-lang.org/). 此组件将在符合以下任意条件时显示: +By default the `red` module shows the currently installed version of [Red](https://www.red-lang.org/). The module will be shown if any of the following conditions are met: - The current directory contains a file with `.red` or `.reds` extension @@ -3427,7 +3492,7 @@ symbol = '🔴 ' ## Ruby -By default the `ruby` module shows the currently installed version of [Ruby](https://www.ruby-lang.org/). 此组件将在符合以下任意条件时显示: +By default the `ruby` module shows the currently installed version of [Ruby](https://www.ruby-lang.org/). The module will be shown if any of the following conditions are met: - 当前目录包含 `Gemfile` 文件 - The current directory contains a `.ruby-version` file @@ -3448,7 +3513,7 @@ Starship gets the current Ruby version by running `ruby -v`. | `detect_folders` | `[]` | Which folders should trigger this module. | | `detect_variables` | `['RUBY_VERSION', 'RBENV_VERSION']` | Which environment variables should trigger this module. | | `style` | `'bold red'` | 此组件的样式。 | -| `disabled` | `false` | 禁用 `ruby` 组件。 | +| `disabled` | `false` | Disables the `ruby` module. | ### 变量 @@ -3471,7 +3536,7 @@ symbol = '🔺 ' ## Rust -By default the `rust` module shows the currently installed version of [Rust](https://www.rust-lang.org/). 此组件将在符合以下任意条件时显示: +By default the `rust` module shows the currently installed version of [Rust](https://www.rust-lang.org/). The module will be shown if any of the following conditions are met: - 当前目录包含 `Cargo.toml` 文件 - 当前目录包含一个使用 `.rs` 扩展名的文件 @@ -3487,7 +3552,7 @@ By default the `rust` module shows the currently installed version of [Rust](htt | `detect_files` | `['Cargo.toml']` | Which filenames should trigger this module. | | `detect_folders` | `[]` | Which folders should trigger this module. | | `style` | `'bold red'` | 此组件的样式。 | -| `disabled` | `false` | 禁用 `rust` 组件。 | +| `disabled` | `false` | Disables the `rust` module. | ### 变量 @@ -3556,7 +3621,7 @@ The `shell` module shows an indicator for currently used shell. ::: tip -此组件默认被禁用。 若要启用此组件,请在配置文件中设置 `disable` 字段为 `false`。 +This module is disabled by default. To enable it, set `disabled` to `false` in your configuration file. ::: @@ -3584,7 +3649,7 @@ The `shell` module shows an indicator for currently used shell. | 字段 | 默认值 | 描述 | | --------- | --- | ---------------------------------------------------------- | | indicator | | Mirrors the value of `indicator` for currently used shell. | -| style\* | | `style`对应值. | +| style\* | | Mirrors the value of option `style`. | *: 此变量只能作为样式字符串的一部分使用 @@ -3761,7 +3826,7 @@ The `status` module displays the exit code of the previous command. If $success_ ::: tip -此组件默认被禁用。 若要启用此组件,请在配置文件中设置 `disable` 字段为 `false`。 +This module is disabled by default. To enable it, set `disabled` to `false` in your configuration file. ::: @@ -3822,7 +3887,7 @@ The `sudo` module displays if sudo credentials are currently cached. The module ::: tip -此组件默认被禁用。 若要启用此组件,请在配置文件中设置 `disable` 字段为 `false`。 +This module is disabled by default. To enable it, set `disabled` to `false` in your configuration file. ::: @@ -3867,7 +3932,7 @@ disabled = false ## Swift -By default the `swift` module shows the currently installed version of [Swift](https://swift.org/). 此组件将在符合以下任意条件时显示: +By default the `swift` module shows the currently installed version of [Swift](https://swift.org/). The module will be shown if any of the following conditions are met: - The current directory contains a `Package.swift` file - The current directory contains a file with the `.swift` extension @@ -3930,7 +3995,7 @@ By default the module will be shown if any of the following conditions are met: | `detect_files` | `[]` | Which filenames should trigger this module. | | `detect_folders` | `['.terraform']` | Which folders should trigger this module. | | `style` | `'bold 105'` | 此组件的样式。 | -| `disabled` | `false` | 禁用 `terraform` 组件。 | +| `disabled` | `false` | Disables the `terraform` module. | ### 变量 @@ -3965,25 +4030,25 @@ format = '[🏎💨 $workspace]($style) ' ## Time -`time` 组件显示当前的 **本地** 时间。 `format` 字段值会提供给 [`chrono`](https://crates.io/crates/chrono) crate 用来控制时间显示方式。 请参阅 [chrono strftime 文档](https://docs.rs/chrono/0.4.7/chrono/format/strftime/index.html) 以了解可用格式选项。 +The `time` module shows the current **local** time. The `format` configuration value is used by the [`chrono`](https://crates.io/crates/chrono) crate to control how the time is displayed. Take a look [at the chrono strftime docs](https://docs.rs/chrono/0.4.7/chrono/format/strftime/index.html) to see what options are available. ::: tip -此组件默认被禁用。 若要启用此组件,请在配置文件中设置 `disable` 字段为 `false`。 +This module is disabled by default. To enable it, set `disabled` to `false` in your configuration file. ::: ### 配置项 -| 选项 | 默认值 | 描述 | -| ----------------- | ----------------------- | ----------------------------------------------------------------------------------------------------- | -| `format` | `'at [$time]($style) '` | The format string for the module. | -| `use_12hr` | `false` | 启用 12 小时格式 | -| `time_format` | 见下文解释 | 用来格式化时间显示的 [chrono 格式字符串](https://docs.rs/chrono/0.4.7/chrono/format/strftime/index.html) | -| `style` | `'bold yellow'` | 显示时间的样式。 | -| `utc_time_offset` | `'local'` | 设置所用 UTC 偏移量。 Range from -24 < x < 24. 允许使用浮点数来得到 30/45 分钟的时区偏移。 | -| `disabled` | `true` | 禁用 `time` 组件。 | -| `time_range` | `'-'` | Sets the time range during which the module will be shown. Times must be specified in 24-hours format | +| 选项 | 默认值 | 描述 | +| ----------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | +| `format` | `'at [$time]($style) '` | The format string for the module. | +| `use_12hr` | `false` | Enables 12 hour formatting | +| `time_format` | see below | The [chrono format string](https://docs.rs/chrono/0.4.7/chrono/format/strftime/index.html) used to format the time. | +| `style` | `'bold yellow'` | The style for the module time | +| `utc_time_offset` | `'local'` | Sets the UTC offset to use. Range from -24 < x < 24. Allows floats to accommodate 30/45 minute timezone offsets. | +| `disabled` | `true` | Disables the `time` module. | +| `time_range` | `'-'` | Sets the time range during which the module will be shown. Times must be specified in 24-hours format | If `use_12hr` is `true`, then `time_format` defaults to `'%r'`. Otherwise, it defaults to `'%T'`. Manually setting `time_format` will override the `use_12hr` setting. @@ -4011,7 +4076,7 @@ time_range = '10:00:00-14:00:00' ## Username -`username` 组件显示当前活跃的用户名。 此组件将在符合以下任意条件时显示: +The `username` module shows active user's username. The module will be shown if any of the following conditions are met: - The current user is root/admin - 当前用户与登录用户不相同 @@ -4029,10 +4094,10 @@ SSH connection is detected by checking environment variables `SSH_CONNECTION`, ` | 选项 | 默认值 | 描述 | | ------------- | ----------------------- | ------------------------------------------- | | `style_root` | `'bold red'` | The style used when the user is root/admin. | -| `style_user` | `'bold yellow'` | 非 root 用户使用的样式。 | +| `style_user` | `'bold yellow'` | The style used for non-root users. | | `format` | `'[$user]($style) in '` | 组件格式化模板。 | -| `show_always` | `false` | 总是显示 `username` 组件。 | -| `disabled` | `false` | 禁用 `username` 组件。 | +| `show_always` | `false` | Always shows the `username` module. | +| `disabled` | `false` | Disables the `username` module. | ### 变量 @@ -4162,7 +4227,7 @@ format = '[🆅 $repo](bold blue) ' ## Zig -By default the `zig` module shows the currently installed version of [Zig](https://ziglang.org/). 此组件将在符合以下任意条件时显示: +By default the `zig` module shows the currently installed version of [Zig](https://ziglang.org/). The module will be shown if any of the following conditions are met: - The current directory contains a `.zig` file @@ -4244,7 +4309,7 @@ Format strings can also contain shell specific prompt sequences, e.g. [Bash](htt | `when` | `false` | Either a boolean value (`true` or `false`, without quotes) or a string shell command used as a condition to show the module. In case of a string, the module will be shown if the command returns a `0` status code. | | `require_repo` | `false` | If `true`, the module will only be shown in paths containing a (git) repository. This option alone is not sufficient display condition in absence of other options. | | `shell` | | [See below](#custom-command-shell) | -| `描述` | `''` | The description of the module that is shown when running `starship explain`. | +| `description` | `''` | The description of the module that is shown when running `starship explain`. | | `detect_files` | `[]` | The files that will be searched in the working directory for a match. | | `detect_folders` | `[]` | The directories that will be searched in the working directory for a match. | | `detect_extensions` | `[]` | The extensions that will be searched in the working directory for a match. | @@ -4258,40 +4323,40 @@ Format strings can also contain shell specific prompt sequences, e.g. [Bash](htt ### 变量 -| 字段 | 描述 | -| --------- | -------------- | -| output | `shell` 中命令的输出 | -| 符号 | `symbol`对应值 | -| style\* | `style`对应值 | +| 字段 | 描述 | +| --------- | -------------------------------------- | +| output | The output of shell command in `shell` | +| 符号 | `symbol`对应值 | +| style\* | `style`对应值 | *: 此变量只能作为样式字符串的一部分使用 #### 自定义命令 shell -`shell` 接受一个非空字符串列表: +`shell` accepts a non-empty list of strings, where: - 第一个字符串是用于执行命令的 shell 路径。 - 剩下的将作为参数传递给 shell。 -如果未设置,它将回退到 STARSHIP_SHELL,然后回退到 Linux 上的 "sh" 命令,在 Windows 上则是 "cmd /C"。 +If unset, it will fallback to STARSHIP_SHELL and then to 'sh' on Linux, and 'cmd /C' on Windows. -`command` 将会被传递给标准输入。 +The `command` will be passed in on stdin. -如果 `shell` 未设置或仅包含一个元素,并且 Starship 检测到正在使用 PowerShell,则会自动添加 `-NoProfile -Command -` 参数。 如果 `shell` 未设置或仅包含一个元素,并且 Starship 检测到正在使用 Cmd,则会自动添加 `/C` 参数,并且将 `stdin` 设置为 `false`。 如果 `shell` 未设置或仅包含一个元素,并且 Starship 检测到正在使用 Cmd,则会自动添加 `-C` 参数,并且将 `stdin` 设置为 `false`。 可以通过将参数显式传递给 shell 来避免这种行为,例如: +If `shell` is not given or only contains one element and Starship detects PowerShell will be used, the following arguments will automatically be added: `-NoProfile -Command -`. If `shell` is not given or only contains one element and Starship detects Cmd will be used, the following argument will automatically be added: `/C` and `stdin` will be set to `false`. If `shell` is not given or only contains one element and Starship detects Nushell will be used, the following arguments will automatically be added: `-c` and `stdin` will be set to `false`. This behavior can be avoided by explicitly passing arguments to the shell, e.g. ```toml shell = ['pwsh', '-Command', '-'] ``` -::: warning 请确保您的自定义 shell 配置正常退出 +::: warning Make sure your custom shell configuration exits gracefully -如果您设置了一个自定义命令, 请确保 starship 使用的默认 shell (在 `shell` 选项设置) 执行命令后会正常退出。 +If you set a custom command, make sure that the default Shell used by starship will properly execute the command with a graceful exit (via the `shell` option). -例如,PowerShell 需要 `-Command` 参数来执行单行命令。 忽略此参数可能导致 starship 无尽递归:shell 可能会尝试加载带有 starship 的完整配置并重新执行自定义命令,导致无尽循环。 +For example, PowerShell requires the `-Command` parameter to execute a one liner. Omitting this parameter might throw starship into a recursive loop where the shell might try to load a full profile environment with starship itself again and hence re-execute the custom command, getting into a never ending loop. -建议使用类似于 PowerShell 中 `-NoProfile` 的启动参数,这样还能避免额外的配置加载时间。 +Parameters similar to `-NoProfile` in PowerShell are recommended for other shells as well to avoid extra loading time of a custom profile on every starship invocation. -自动检测 shell 和添加适当的参数的功能已被实现,但包含的 shell 支持可能有缺漏。 遇到这种情况,请[提交一个带有 shell 信息和 starship 配置的 issue](https://github.com/starship/starship/issues/new/choose)。 +Automatic detection of shells and proper parameters addition are currently implemented, but it's possible that not all shells are covered. [Please open an issue](https://github.com/starship/starship/issues/new/choose) with shell details and starship configuration if you hit such scenario. ::: @@ -4301,19 +4366,19 @@ shell = ['pwsh', '-Command', '-'] # ~/.config/starship.toml [custom.foo] -command = 'echo foo' # 显示命令输出 -detect_files = ['foo'] # 支持过滤器,但不支持通配符 +command = 'echo foo' # shows output of command +detect_files = ['foo'] # can specify filters but wildcards are not supported when = ''' test "$HOME" = "$PWD" ''' format = ' transcending [$output]($style)' [custom.time] command = 'time /T' -detect_extensions = ['pst'] # 识别 *.pst 文件 +detect_extensions = ['pst'] # filters *.pst files shell = ['pwsh.exe', '-NoProfile', '-Command', '-'] [custom.time-as-arg] command = 'time /T' -detect_extensions = ['pst'] # 识别 *.pst 文件 +detect_extensions = ['pst'] # filters *.pst files shell = ['pwsh.exe', '-NoProfile', '-Command'] use_stdin = false ```