mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-08-09 19:27:47 +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
|
||||
}
|
||||
|
||||
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 {
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user