diff --git a/kubectx b/kubectx index 802d1bd..f00cece 100755 --- a/kubectx +++ b/kubectx @@ -22,22 +22,27 @@ set -eou pipefail IFS=$'\n\t' SELF_CMD="$0" +SELF="kubectx" +if [[ "$(basename "$0")" == kubectl-* ]]; then # invoked as plugin + SELF="kubectl ctx" +fi + KUBECTX="${XDG_CACHE_HOME:-$HOME/.kube}/kubectx" usage() { - cat <<"EOF" + cat < : switch to context - kubectx - : switch to the previous context - kubectx -c, --current : show the current context name - kubectx = : rename context to - kubectx =. : rename current-context to - kubectx -d [] : delete context ('.' for current-context) + $SELF : list the contexts + $SELF : switch to context + $SELF - : switch to the previous context + $SELF -c, --current : show the current context name + $SELF = : rename context to + $SELF =. : rename current-context to + $SELF -d [] : delete context ('.' for current-context) (this command won't delete the user/cluster entry that is used by the context) - kubectx -h,--help : show this message + $SELF -h,--help : show this message EOF } diff --git a/kubens b/kubens index 64d6460..8ca7eba 100755 --- a/kubens +++ b/kubens @@ -22,16 +22,21 @@ set -eou pipefail IFS=$'\n\t' SELF_CMD="$0" +SELF="kubens" +if [[ "$(basename "$0")" == kubectl-* ]]; then # invoked as plugin + SELF="kubectl ns" +fi + KUBENS_DIR="${XDG_CACHE_HOME:-$HOME/.kube}/kubens" usage() { - cat <<"EOF" + cat < : change the active namespace of current context - kubens - : switch to the previous namespace in this context - kubens -c, --current : show the current namespace - kubens -h,--help : show this message + $SELF : list the namespaces in the current context + $SELF : change the active namespace of current context + $SELF - : switch to the previous namespace in this context + $SELF -c, --current : show the current namespace + $SELF -h,--help : show this message EOF }