From 5b6d20d0bd2df0a578a6c9b70405f5a780355360 Mon Sep 17 00:00:00 2001 From: fj0r <82698591+fj0r@users.noreply.github.com> Date: Wed, 3 May 2023 19:57:42 +0800 Subject: [PATCH] Fix the problem that the KUBECONFIG file does not exist (#476) Co-authored-by: agent --- modules/prompt/powerline/power_kube.nu | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/prompt/powerline/power_kube.nu b/modules/prompt/powerline/power_kube.nu index ad5753a..cbd37ec 100644 --- a/modules/prompt/powerline/power_kube.nu +++ b/modules/prompt/powerline/power_kube.nu @@ -13,6 +13,7 @@ def ensure-cache [cache path action] { def "kube ctx" [] { let cache = $'($env.HOME)/.cache/nu-power/kube.json' let file = if ($env.KUBECONFIG? | is-empty) { $"($env.HOME)/.kube/config" } else { $env.KUBECONFIG } + if not ($file | path exists) { return $nothing } ensure-cache $cache $file { do -i { kubectl config get-contexts @@ -26,10 +27,10 @@ def "kube ctx" [] { def kube_stat [] { {|| let ctx = (kube ctx) - let theme = $env.NU_POWER_THEME.kube if ($ctx | is-empty) { "" } else { + let theme = $env.NU_POWER_THEME.kube let c = if $ctx.AUTHINFO == $ctx.CLUSTER { $ctx.CLUSTER } else {