--- /dev/null
+function __k8s() {
+ local text=
+ if [ -n "$KUBECTL_NAMESPACE" ]; then
+ if [ ! "$KUBECTL_NAMESPACE" = "default" ]; then
+ echo -n "$1$KUBECTL_NAMESPACE"
+ return 0
+ fi
+ fi
+}
+
+function context() {
+ if [ "$1" = "reset" ]; then
+ unset KUBECTL_CONTEXT
+ elif [ -n "$1" ]; then
+ export KUBECTL_CONTEXT=$1
+ elif [ -n "$KUBECTL_CONTEXT" ]; then
+ echo "$KUBECTL_CONTEXT"
+ else
+ kubectl config current-context
+ fi
+}
+
+function namespace() {
+ if [ "$1" = "reset" ]; then
+ unset KUBECTL_NAMESPACE
+ elif [ -n "$1" ]; then
+ export KUBECTL_NAMESPACE=$1
+ elif [ -n "$KUBECTL_NAMESPACE" ]; then
+ echo "$KUBECTL_NAMESPACE"
+ else
+ return 1
+ fi
+}
--- /dev/null
+#!/bash
+
+# This part of the prompt is taken from k8s.bashrc.
+# It is shown only if __ps1_k8s is 1. By default it is 0.
+
+__ps1_k8s=${__ps1_k8s:-0}
+__ps1_k8s_colour256="0;38;5;127"
+__ps1_k8s_colour88="0;38;5;49"
+__ps1_k8s_colour="0;35"
+
+function __ps1_k8s() {
+ [ "$__ps1_k8s" = "1" ] || return $1
+ __k8s "$(__ps1_prefix $1 __ps1_k8s)"
+ return $1
+}
--- /dev/null
+#!/bin/bash
+
+cmd=/usr/bin/kubectl
+args=""
+
+[ -n "$KUBECTL_CONTEXT" ] && args="$args --context $KUBECTL_CONTEXT"
+[ -n "$KUBECTL_NAMESPACE" ] && args="$args --namespace $KUBECTL_NAMESPACE"
+
+exec $cmd $args ${1+"$@"}