From e85afcb3644f1af87af99442c7485862da0d26a8 Mon Sep 17 00:00:00 2001 From: Luna Komorebi Date: Wed, 8 Nov 2023 01:27:18 +0100 Subject: [PATCH] Add lazy loading and autocompletion for kubectl --- .zsh/lazy.zsh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .zsh/lazy.zsh diff --git a/.zsh/lazy.zsh b/.zsh/lazy.zsh new file mode 100644 index 0000000..5166a1f --- /dev/null +++ b/.zsh/lazy.zsh @@ -0,0 +1,19 @@ +#!/usr/bin/env zsh + +# Check if 'kubectl' is a command in $PATH +if [ $commands[kubectl] ]; then + + # Placeholder 'kubectl' shell function: + # Will only be executed on the first call to 'kubectl' + kubectl() { + + # Remove this function, subsequent calls will execute 'kubectl' directly + unfunction "$0" + + # Load auto-completion + source <(kubectl completion zsh) + + # Execute 'kubectl' binary + $0 "$@" + } +fi