From 4ec1d1707432daeb9891cf4f4e8e657bf04e68e6 Mon Sep 17 00:00:00 2001 From: Jans Rautenbach <14095706+J4NS-R@users.noreply.github.com> Date: Sat, 28 Nov 2026 02:33:03 +0000 Subject: [PATCH] feat(kubectl): add `kcgetns` alias to show the current namespace (#13215) * rebase and review changes * full command in readme * space --- plugins/kubectl/README.md | 1 + plugins/kubectl/kubectl.plugin.zsh | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/kubectl/README.md b/plugins/kubectl/README.md index ffd065b6b..95ef190fd 100644 --- a/plugins/kubectl/README.md +++ b/plugins/kubectl/README.md @@ -60,6 +60,7 @@ plugins=(... kubectl) | | | **Namespace management** | | kgns | `kubectl get namespaces` | List the current namespaces in a cluster | | kcn | `kubectl config set-context --current --namespace` | Change current namespace | +| kcgetns | `kubectl config view --minify -o jsonpath={.contexts[0].context.namespace}` | Get the current context's namespace | | kens | `kubectl edit namespace` | Edit namespace resource from the default editor | | kdns | `kubectl describe namespace` | Describe namespace resource in detail | | kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace | diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index 94717eda7..d19ab07b4 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -31,7 +31,7 @@ alias kapk='kubectl apply -k' # Drop into an interactive terminal on a container alias keti='kubectl exec -t -i' -# Manage configuration quickly to switch contexts between local, dev ad staging. +# Manage configuration quickly to switch contexts between local, dev and staging. alias kcuc='kubectl config use-context' alias kcsc='kubectl config set-context' alias kcdc='kubectl config delete-context' @@ -83,6 +83,7 @@ alias kens='kubectl edit namespace' alias kdns='kubectl describe namespace' alias kdelns='kubectl delete namespace' alias kcn='kubectl config set-context --current --namespace' +alias kcgetns="kubectl config view --minify -o 'jsonpath={.contexts[0].context.namespace}'" # ConfigMap management alias kgcm='kubectl get configmaps'