From c042ff4d416534aa64deede06a4191c10729fc78 Mon Sep 17 00:00:00 2001 From: Florian Rey Date: Sun, 13 Oct 2024 18:21:58 +0200 Subject: [PATCH] feat(stern): introduce stern plugin --- plugins/stern/README.md | 9 +++++++++ plugins/stern/stern.plugin.zsh | 14 ++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 plugins/stern/README.md create mode 100644 plugins/stern/stern.plugin.zsh diff --git a/plugins/stern/README.md b/plugins/stern/README.md new file mode 100644 index 000000000..29ffe2cd5 --- /dev/null +++ b/plugins/stern/README.md @@ -0,0 +1,9 @@ +# Stern plugin + +This plugin adds completion for [Stern](https://github.com/stern/stern), the multi pod and container log tailing for Kubernetes. + +To use it, add `stern` to the plugins array in your zshrc file: + +```zsh +plugins=(... stern) +``` diff --git a/plugins/stern/stern.plugin.zsh b/plugins/stern/stern.plugin.zsh new file mode 100644 index 000000000..6e194e232 --- /dev/null +++ b/plugins/stern/stern.plugin.zsh @@ -0,0 +1,14 @@ +# Completion +if (( ! $+commands[stern] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `stern`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_stern" ]]; then + typeset -g -A _comps + autoload -Uz _stern + _comps[stern]=_stern +fi + +stern --completion zsh >| "$ZSH_CACHE_DIR/completions/_stern" &|