e9b11c37e82ee3949680458dc0e45c79fe52332b

Author
TheEdgeOfRage <git@theedgeofrage.com>
Committer
TheEdgeOfRage <git@theedgeofrage.com>
Date

Message

Update kc script

Diff

 1diff --git a/dot_config/zsh/kc.zsh b/dot_config/zsh/kc.zsh
 2index 7bcac5e51b40a90a300597e8e4abdd4712fee7b0..4c8030746a2d201ad993a0c3e887a41d13534c2c 100644
 3--- a/dot_config/zsh/kc.zsh
 4+++ b/dot_config/zsh/kc.zsh
 5@@ -7,9 +7,9 @@ usage() {
 6   cat <<EOF
 7 USAGE:
 8   $SELF                       : list the configs
 9-  $SELF <NAME>                : switch to context <NAME>
10+  $SELF <NAME>                : switch to config <NAME>
11   $SELF -c, --current         : show the current context name
12-  $SELF -u, --unset           : unset the current context, better use: Ctrl+d
13+  $SELF -u, --unset           : unset the current kubeconfig
14 
15   $SELF -h,--help             : show this message
16 EOF
17@@ -26,7 +26,7 @@ current_context() {
18 
19 get_configs() {
20   #kubectl config get-contexts -o=name | sort -n
21-  ls -p --color=never -1 $HOME/.kube | \grep -v '/$'
22+  \ls -p --color=never -1 $HOME/.kube | \grep -v '/$'
23 }
24 
25 list_configs() {
26@@ -75,8 +75,7 @@ set_context() {
27 }
28 
29 unset_context() {
30-  unset $KUBECONFIG
31-  kubectl config unset current-context
32+  unset KUBECONFIG
33 }
34 
35 kc() {
36@@ -91,12 +90,7 @@ kc() {
37     usage
38     exit 1
39   elif [[ "$#" -eq 1 ]]; then
40-    if [[ "${1}" == "-" ]]; then
41-      swap_context
42-    elif [[ "${1}" == '-c' || "${1}" == '--current' ]]; then
43-      # we don't call current_context here for two reasons:
44-      # - it does not fail when current-context property is not set
45-      # - it does not return a trailing newline
46+    if [[ "${1}" == '-c' || "${1}" == '--current' ]]; then
47       kubectl config current-context
48     elif [[ "${1}" == '-u' || "${1}" == '--unset' ]]; then
49       unset_context