mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 13:46:41 +00:00
chore(shell/kubernetes): improve kubectx completion setup
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user