summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphaël Pinson <github+aem1eeshi1@raphink.net>2020-10-08 19:18:43 +0200
committerGitHub <noreply@github.com>2020-10-08 19:18:43 +0200
commit68f809448a08d2c93d13650157fd0500a329a16a (patch)
tree246d9899a5ea1fb3b5f0d03ff1e0cf6c63db45bc
parent27857e66d0dab0bd05790307dfe5388f3cb2c51a (diff)
downloadzsh-68f809448a08d2c93d13650157fd0500a329a16a.tar.gz
zsh-68f809448a08d2c93d13650157fd0500a329a16a.tar.bz2
zsh-68f809448a08d2c93d13650157fd0500a329a16a.zip
kubectl: add wrappers for colorized output in JSON and YAML (#9316)
Co-authored-by: Marc Cornellà <marc.cornella@live.com>
-rw-r--r--plugins/kubectl/README.md8
-rw-r--r--plugins/kubectl/kubectl.plugin.zsh16
2 files changed, 24 insertions, 0 deletions
diff --git a/plugins/kubectl/README.md b/plugins/kubectl/README.md
index ee05a8af1..84f5f8d89 100644
--- a/plugins/kubectl/README.md
+++ b/plugins/kubectl/README.md
@@ -106,3 +106,11 @@ plugins=(... kubectl)
| kdelss | `kubectl delete statefulset` | Delete the statefulset |
| ksss | `kubectl scale statefulset` | Scale a statefulset |
| krsss | `kubectl rollout status statefulset`| Check the rollout status of a deployment |
+
+## Wrappers
+
+This plugin provides 3 wrappers to colorize kubectl output in JSON and YAML using various tools (which must be installed):
+
+- `kj`: JSON, colorized with [`jq`](https://stedolan.github.io/jq/).
+- `kjx`: JSON, colorized with [`fx`](https://github.com/antonmedv/fx).
+- `ky`: YAML, colorized with [`yh`](https://github.com/andreazorzetto/yh).
diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh
index 647d029c1..6292a0b2f 100644
--- a/plugins/kubectl/kubectl.plugin.zsh
+++ b/plugins/kubectl/kubectl.plugin.zsh
@@ -150,3 +150,19 @@ alias kepvc='kubectl edit pvc'
alias kdpvc='kubectl describe pvc'
alias kdelpvc='kubectl delete pvc'
+# Colored JSON output
+kj() {
+ kubectl "$@" -o json | jq
+}
+compdef kj=kubectl
+
+kjx() {
+ kubectl "$@" -o json | fx
+}
+compdef kjx=kubectl
+
+# Colored YAML output
+ky() {
+ kubectl "$@" -o yaml | yh
+}
+compdef ky=kubectl