#!/bin/bash -i

USAGE="k8env manages Kubernetes contexts.

usage: k8env [-h] CONTEXT"

if [ -z "$1" ]; then
    echo "$USAGE";
    exit;
fi;

KUBECONTEXT=$1

if [ -z "$PREV_PS1" ]; then
    PREV_PS1="$PS1";
fi;
NEW_PS1="(k8:$KUBECONTEXT)$PREV_PS1";


bash --init-file <(echo "
    alias kubectl='`which kubectl` --context $KUBECONTEXT';
    export PREV_PS1='$PREV_PS1';
    export PS1='$NEW_PS1';
") -i
