fix(kubernetes): fix bug with kubectx completions setup

This commit is contained in:
2023-09-18 11:27:48 +01:00
parent f6e49a661b
commit c51fde5e70

View File

@@ -42,13 +42,14 @@ fi
_setup-kubectx-completion() { _setup-kubectx-completion() {
local cmd="$1" local cmd="$1"
local dir="$HOME/.local/share/rtx/installs/kubectx/latest/completion/" local dir="$HOME/.local/share/rtx/installs/kubectx/latest/completion"
local target="$ZSH_COMPLETIONS/_${cmd}"
if [ -f "$ZSH_COMPLETIONS/_${cmd}" ] || [ !-d "$dir" ]; then if [ -f "$target" ] || [ ! -d "$dir" ]; then
return return
fi fi
echo "Setting up completion for $cmd -- $ZSH_COMPLETIONS/_${cmd}" echo "Setting up completion for $cmd -- $target"
local script local script
if [ -f "${dir}/${cmd}.zsh" ]; then if [ -f "${dir}/${cmd}.zsh" ]; then
@@ -57,8 +58,9 @@ _setup-kubectx-completion() {
script="$dir/_${cmd}.zsh" script="$dir/_${cmd}.zsh"
fi fi
echo " - Sym-linking from $script"
mkdir -p "$ZSH_COMPLETIONS" mkdir -p "$ZSH_COMPLETIONS"
ln -s "$script" "$ZSH_COMPLETIONS/_${cmd}" ln -s "$script" "$target"
} }
if command-exists kubectx && ! which _kubectx &> /dev/null; then if command-exists kubectx && ! which _kubectx &> /dev/null; then