From a9d99c9cab69bd52edd3584ea426d8dacd6e8929 Mon Sep 17 00:00:00 2001 From: venyii Date: Fri, 5 Jul 2019 01:10:26 +0200 Subject: [PATCH 1/2] Add ability to provide a cluster function in kubecontext segment This makes it possible to customize the displayed cluster name, e.g. `gke_project-name-1337_europe-west1-c_production` -> `production` --- EXTENDED_CONFIGURATION.md | 13 +++++++++++++ internal/p10k.zsh | 3 +++ 2 files changed, 16 insertions(+) diff --git a/EXTENDED_CONFIGURATION.md b/EXTENDED_CONFIGURATION.md index 048f3bf2..ced06cd2 100644 --- a/EXTENDED_CONFIGURATION.md +++ b/EXTENDED_CONFIGURATION.md @@ -43,6 +43,19 @@ another You can pick up a fix for the latter from [a fork of zsh](https://github.com/romkatv/zsh/tree/gentle-reset-prompt). +`POWERLEVEL9K_KUBECONTEXT_CONTEXT_FUNCTION (FUNCTION) [default=""]` + +Add your own function to modify the k8s context name, e.g. remove superfluous information: + +```bash +# Input: gke_project-name-1337_europe-west1-c_production/ns +# Output: production +function k8s_context_short() { + echo "$1" | sed -E 's/.*-[a-z]_(.*)\/.*/\1/' +} +POWERLEVEL9K_KUBECONTEXT_CONTEXT_FUNCTION="k8s_context_short" +``` + When using gitstatus, there is an extra state called `LOADING` that is used by `vcs` prompt segment when it's waiting for git status in the background. You can define styling for this state the same way as for the other states -- `CLEAN`, `UNTRACKED` and `MODIFIED`. You can diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 825fd772..a1cbe3e0 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -2126,6 +2126,9 @@ prompt_kubecontext() { fi done fi + if [[ -n $POWERLEVEL9K_KUBECONTEXT_CONTEXT_FUNCTION ]]; then + ctx=$($POWERLEVEL9K_KUBECONTEXT_CONTEXT_FUNCTION $ctx) + fi _p9k_cache_set "$ctx" "$suf" fi From a74603d30f2e1fbbffc53346382ac280725a06c6 Mon Sep 17 00:00:00 2001 From: venyii Date: Fri, 5 Jul 2019 01:13:36 +0200 Subject: [PATCH 2/2] Fix README typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a6c98b3..15968e5d 100644 --- a/README.md +++ b/README.md @@ -205,7 +205,7 @@ budget for other plugins you might install. Powerlevel10k is released under the [MIT license](https://github.com/romkatv/powerlevel10k/blob/master/LICENSE). Contributions are -convered by the same license. +covered by the same license. ## FAQ