chore(shell/kubernetes): improve kubectx completion setup

This commit is contained in:
2024-10-18 12:14:28 +01:00
parent d3b5a0c2ab
commit 743f99db4f

View File

@@ -33,28 +33,11 @@ fi
_setup-kubectx-completion() { _setup-kubectx-completion() {
local cmd="$1" local cmd="$1"
local dir="$HOME/.local/share/mise/installs/kubectx/latest/completion" local dir="$HOME/.local/share/mise/installs/kubectx/latest/completion"
local target="$ZSH_COMPLETIONS/_${cmd}" local src="${dir}/_${cmd}.zsh"
if [[ -f "$target" || ! -d "$dir" ]]; then if [[ ! -f "$src" ]]; then return; fi
return
fi
echo "Setting up completion for $cmd -- $target" setup-completions "$cmd" "$src" cat "$src"
local script
if [ -f "${dir}/${cmd}.zsh" ]; then
script="$dir/${cmd}.zsh"
elif [ -f "${dir}/_${cmd}.zsh" ]; then
script="$dir/_${cmd}.zsh"
fi
echo " - Sym-linking from $script"
mkdir -p "$ZSH_COMPLETIONS"
ln -s "$script" "$target"
if ! (whence -w compinit &> /dev/null); then
autoload -U compinit && compinit
fi
} }
if command-exists kubectx; then if command-exists kubectx; then