From 5152d381bb828a4ed41fdbb430eb05970a8bb25c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Szyd=C5=82o?= Date: Sun, 13 Jun 2021 17:23:13 +0200 Subject: [PATCH] feat(kubectx): adding a new plugin for 'kubectx' (#6114) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà Co-authored-by: Robby Russell --- lib/prompt_info_functions.zsh | 1 + plugins/kubectx/README.md | 26 ++++++++++++++++++++++++++ plugins/kubectx/kubectx.plugin.zsh | 14 ++++++++++++++ plugins/kubectx/prod.png | Bin 0 -> 3834 bytes plugins/kubectx/stage.png | Bin 0 -> 3829 bytes 5 files changed, 41 insertions(+) create mode 100644 plugins/kubectx/README.md create mode 100644 plugins/kubectx/kubectx.plugin.zsh create mode 100644 plugins/kubectx/prod.png create mode 100644 plugins/kubectx/stage.png diff --git a/lib/prompt_info_functions.zsh b/lib/prompt_info_functions.zsh index 48f033da6..e29fb27a5 100644 --- a/lib/prompt_info_functions.zsh +++ b/lib/prompt_info_functions.zsh @@ -19,6 +19,7 @@ function chruby_prompt_info \ virtualenv_prompt_info \ jenv_prompt_info \ tf_prompt_info \ + kubectx_prompt_info \ { return 1 } diff --git a/plugins/kubectx/README.md b/plugins/kubectx/README.md new file mode 100644 index 000000000..9a1df2617 --- /dev/null +++ b/plugins/kubectx/README.md @@ -0,0 +1,26 @@ +# kubectx - show active kubectl context + +This plugins adds ```kubectx_prompt_info()``` function. It shows name of the +active kubectl context (```kubectl config current-context```). + +You can use it to customize prompt and know if You are on prod cluster ;) + +_Example_. Add to **.zshrc**: + +``` +RPS1='$(kubectx_prompt_info)' +``` + +### custom ctx names + +One can rename default context name for better readability. + +_Example_. Add to **.zshrc**: +``` +kubectx_mapping[minikube] = "mini" +kubectx_mapping[context_name_from_kubeconfig]="$emoji[wolf_face]" +kubectx_mapping[production_cluster]="%{$fg[yellow]%}prod!%{$reset_color%}" +``` + +![staging](stage.png) +![production](prod.png) diff --git a/plugins/kubectx/kubectx.plugin.zsh b/plugins/kubectx/kubectx.plugin.zsh new file mode 100644 index 000000000..56b7217f1 --- /dev/null +++ b/plugins/kubectx/kubectx.plugin.zsh @@ -0,0 +1,14 @@ +typeset -A kubectx_mapping + +function kubectx_prompt_info() { + if [ $commands[kubectl] ]; then + local current_ctx=`kubectl config current-context` + + #if associative array declared + if [[ -n $kubectx_mapping ]]; then + echo "${kubectx_mapping[$current_ctx]}" + else + echo $current_ctx + fi + fi +} diff --git a/plugins/kubectx/prod.png b/plugins/kubectx/prod.png new file mode 100644 index 0000000000000000000000000000000000000000..0c194a66d357e3089e26470e54bcd9cd1614aca0 GIT binary patch literal 3834 zcmd6qXH-*Zx5uNRqLdd9DN2#z7)FpL5Rf7SVGTINGD(2YA%Fs5z<`D3Xrx9F z5fCXE3Pj{{R;hg6@d!6$bm_e##iL@`y|PVyUQ3e*~ZF^(6O=U8SO{S{AE96DKJTv?2GjAx;JasBpNafB^n9 z=ykw;71=%0i!O-lwMyV}(Tf3wsjebB!%wnAWPjSO1U)J;q#6DnERgW_L~G1d?EDWK zmyzs+HN|bOgw?sM50rv-j0cBTt@XPJONDelHZyc(C|w)EQgr}NZ?;|!#%_!{vAH+O z)O;ScEPbQoH>$=?ZSZPrwvB^n#D>)cUN>L8N^RrqsQ|&1#ol&BcQb2&X7C8)n40B_ z^>-sKrNMbO^&hbw>JH89v0;{_eoo(B`MpvzOo2Af@I?TDLZR zDiFtB!-Rm-3qg@759KwCF*F%psgisr8sFM(2nIarFFRhn zIo)!i&GoG*Q>s)9lsW00SM0PB^>ur`)nFNxBD5|@QL1ic6@yUe`;$m zh4wG3?f%{nIUp_HpC)sG<{9S9`Ud)oB!KU&H5zr`ED5F-e}tBUX{#?@`n1kZ@w&>v zUV)`cBX_K)(jr@;X6Hk08)uPWJq?JJT-FDdhocPoR*-HPU6s$`@dIRE?@icIEE$KF zSL>AYzTEUQ8+ItwE}*bz5{R-R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m6R^K5%06UCD zsz=^rGz@2cZ5r*0cq_g#v^@Gp$2(mg&wK2C$`PXBNasDTH}an{4KD1hlKIaX*wbJP zh-hT}=J2y3Q(lktgmg)Ik~MejaVUkXd?C=E>zTXuyYBMYka6#sGF)a!)2(s)TenZk z2hXn`|8ccG<(?9nsSs-eQzYl47Y5r)&FQmNxz3h~Mf#%|?;IRXZHA4-Zlmf-ln~6+ zBAgdV3zwCiF|@;myT}j9nbd6$hZhJ5O+EmKbSDg-S0j7pz_jkQ zSBYPoKVyMEB2&uich@v{u#B&$Jke%OOQ`x3*0Ut2T(ohYz3$v5$@&N9G*~@oqw*{EIEu=rvED2beg}H4)U}spZE!=kwV&hdDI>#1bl*yR#a@zuWqaK#XS5J)hcZyTc9(Fuzva~j%b+f56 zEtTQMX+-7Ou*0bB=@YHVZ%@wRkZTmH)U07lFMvzxD?xUdk>}&qZ9k10(f)ic<^1Cxd zjQ_Odxn%xV+)h8MU5D!M%!tI>VUTlH1rUH=MT`MR@@?X@A}? z#x*5kepSD>yZ>x-rAQ6TUX(q_mr)jw6TmdIkYHHX6MLy0rY7*!rzjvnE`&@m9I?}( zMF|YtEU^1R6;2xu*N9X@t;d=E%A7XTj*}A4O_C7`zw!}+H)swnER#wx#FhS39MKx! zfH$F>pPq&~C|J`r5rRN`$3stQ(``smlqwwX?(Zxzt{k*A7Cb4o@TTAy4>z7@QDbi# z&aT$aRcrnC(_8V}cFK+LNd?>~-##iil3@Hyg=YQ=#9R4C)38!B{U4b(wo2Tv{6$Gl zUJ%ING@&1StsvHCG460#%zgc7s-fgNf}Hn5ou6KL*<<>fhn0Wop8!Q80$uyR>?c`b z+`ZHPms9SdcvpV?TRlNe_5Od5Rib+OUxi)DC}rKI%Oq)?J5ZZ1)T;o<8E5-yJKyAg E10~p6Gynhq literal 0 HcmV?d00001 diff --git a/plugins/kubectx/stage.png b/plugins/kubectx/stage.png new file mode 100644 index 0000000000000000000000000000000000000000..ac15b392997ee141c324548c6924fe92a82f72f9 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