From c8f0d4d729c3d0f5e22d615715532b263a93a6d7 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Fri, 17 Feb 2023 15:34:43 +0100 Subject: [PATCH] Better k9s alias --- zsh/aliases.zsh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh index 41d31c4..e3f6dbb 100644 --- a/zsh/aliases.zsh +++ b/zsh/aliases.zsh @@ -79,7 +79,20 @@ fi # Docker and kubernetes aliases command -v k9s > /dev/null 2>&1 if [ $? -eq 0 ]; then - alias kns="k9s" + kns() { + local kube_config + if [ -z $KUBECONFIG ]; then + kube_config=$HOME/.kube/config + else + kube_config=$KUBECONFIG + fi + if [ -f $kube_config ]; then + k9s + else + echo >&2 error: $kube_config does not exist + return 1 + fi + } fi command -v lazydocker > /dev/null 2>&1