Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwpeterson/cb4fb808900032b8a0ef24b63c8fe9e7 to your computer and use it in GitHub Desktop.
Save mwpeterson/cb4fb808900032b8a0ef24b63c8fe9e7 to your computer and use it in GitHub Desktop.
function kctx()
function kctx() {
_die() {
printf '%s\n' "$1" >&2
return 1
}
context="$1"
context_config_dir="$HOME/.kube/ctxcfg"
if [ -f "${context_config_dir}/${context}" ] ; then
export KUBECONFIG="${context_config_dir}/${context}"
else
echo "Specify a context: kctx <context>"
ls -1 $context_config_dir
_die "${context} not found in ${context_config_dir}"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment