mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-04-10 04:26:17 +02:00
feat(kube-ps1): add environment indicator to the prompt layout
This commit is contained in:
parent
8df5c1b18b
commit
259ee26071
2 changed files with 86 additions and 0 deletions
|
|
@ -127,6 +127,10 @@ The default prompt layout is:
|
|||
```sh
|
||||
(<symbol>|<context>:<namespace>)
|
||||
```
|
||||
You can enable kube environment context (like dev/staging/test/prod) via `KUBE_ENV_CTX_ENABLE=true`. In this case, the layout will be:
|
||||
```sh
|
||||
[<kube-environment>] (<symbol>|<context>:<namespace>)
|
||||
```
|
||||
|
||||
If the current-context is not set, kube-ps1 will return the following:
|
||||
|
||||
|
|
@ -204,6 +208,23 @@ the following variables:
|
|||
| `KUBE_PS1_CTX_COLOR_FUNCTION` | No default, must be user supplied | Function to customize context color based on context name |
|
||||
| `KUBE_PS1_HIDE_IF_NOCONTEXT` | `false` | Hide the kube-ps1 prompt if no context is set |
|
||||
|
||||
In case you would like to have more control over kube environment context, you can tackle:
|
||||
|
||||
| Variable | Default | Meaning |
|
||||
| :------- | :-----: | ------- |
|
||||
| `KUBE_ENV_CTX_ENABLE` | `false` | Extract environment identifiers from `kube_ps1` context and display them as a separate block in square brackets |
|
||||
| `KUBE_ENV_PADDING` | ` ` | Padding (spaces or characters) added around the environment block |
|
||||
| `KUBE_ENV_OPEN_SYMBOL` | `[` | Opening symbol used for the environment block |
|
||||
| `KUBE_ENV_CLOSE_SYMBOL` | `]${KUBE_ENV_PADDING}` | Closing symbol used for the environment block |
|
||||
| `KUBE_ENV_PROD` | `prod` | Set default production label |
|
||||
| `KUBE_ENV_STG` | `stag` | Set default staging label |
|
||||
| `KUBE_ENV_TEST` | `test` | Set default testing label |
|
||||
| `KUBE_ENV_DEV` | `dev` | Set default developing label |
|
||||
| `KUBE_ENV_PROD_RE` | `(production|prod)-` | Regex used to detect production in the context name |
|
||||
| `KUBE_ENV_STG_RE` | `(staging|stg)-` | Regex used to detect staging in the context name |
|
||||
| `KUBE_ENV_TEST_RE` | `(testing|test)-` | Regex used to detect test in the context name |
|
||||
| `KUBE_ENV_DEV_RE` | `develop-` | Regex used to detect development in the context name|
|
||||
|
||||
To disable a feature, set it to an empty string:
|
||||
|
||||
```sh
|
||||
|
|
@ -223,6 +244,15 @@ The default colors are set with the following variables:
|
|||
| `KUBE_PS1_NS_COLOR` | `cyan` | Set default color of the namespace |
|
||||
| `KUBE_PS1_BG_COLOR` | `null` | Set default color of the prompt background |
|
||||
|
||||
If `KUBE_ENV_CTX_ENABLE` set to `true`, you can also adjust:
|
||||
|
||||
| Variable | Default | Meaning |
|
||||
| :------- | :-----: | ------- |
|
||||
| `KUBE_ENV_PROD_COLOR` | `red` | Set default color of the production environment |
|
||||
| `KUBE_ENV_STG_COLOR` | `yellow` | Set default color of the staging environment |
|
||||
| `KUBE_ENV_TEST_COLOR` | `green` | Set default color of the testing environment |
|
||||
| `KUBE_ENV_DEV_COLOR` | `blue` | Set default color of the development environment |
|
||||
|
||||
Blue was used for the default symbol to match the Kubernetes color as closely
|
||||
as possible. Red was chosen as the context name to stand out, and cyan for the
|
||||
namespace.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue