Skip to content

Instantly share code, notes, and snippets.

@dracorp
Created April 17, 2019 15:03
Show Gist options
  • Save dracorp/060794d005a66eb12b5ef1bd473aa2e0 to your computer and use it in GitHub Desktop.
Save dracorp/060794d005a66eb12b5ef1bd473aa2e0 to your computer and use it in GitHub Desktop.
Put this file into ~/.bash-it/custom/
function k8s_context_prompt {
local kube_namespace
kube_namespace="$(kubectl config view --minify --output 'jsonpath={..namespace}' 2>/dev/null)"
# Set namespace to 'default' if it is not defined
kube_namespace="${kube_namespace:-default}"
echo -e "$(kubectl config current-context):${kube_namespace}"
}
@dracorp
Copy link
Author

dracorp commented Apr 17, 2019

To enable kubectl current context in your prompt add to POWERLINE_PROMPT variable value: k8s_context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment