mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-08-12 12:41:55 +00:00
Show current context with colors
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
parent
43f2aec038
commit
7ac1963235
21
kubectx
21
kubectx
@ -29,9 +29,28 @@ USAGE:
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function current_context {
|
||||||
|
kubectl config view -o=jsonpath='{.current-context}'
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_contexts {
|
||||||
|
kubectl config get-contexts | awk '{print $2}' | tail -n +2
|
||||||
|
}
|
||||||
|
|
||||||
function list_contexts {
|
function list_contexts {
|
||||||
set -u pipefail
|
set -u pipefail
|
||||||
kubectl config get-contexts | awk '{print $2}' | tail -n +2
|
local cur="$(current_context)"
|
||||||
|
local bold=$(tput bold)
|
||||||
|
local yellow=$(tput setaf 3)
|
||||||
|
local normal=$(tput sgr0)
|
||||||
|
|
||||||
|
for c in $(get_contexts); do
|
||||||
|
if [[ "$c" = "$cur" ]]; then
|
||||||
|
echo "${bold}${yellow}$c${normal}"
|
||||||
|
else
|
||||||
|
echo "$c"
|
||||||
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function read_context {
|
function read_context {
|
||||||
|
Loading…
Reference in New Issue
Block a user