From c51fde5e70256bd7b0d327836e8971b480f9dde3 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Mon, 18 Sep 2023 11:27:48 +0100 Subject: [PATCH] fix(kubernetes): fix bug with kubectx completions setup --- zsh/kubernetes.zsh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/zsh/kubernetes.zsh b/zsh/kubernetes.zsh index 80ec7fa..51b31f5 100644 --- a/zsh/kubernetes.zsh +++ b/zsh/kubernetes.zsh @@ -42,13 +42,14 @@ fi _setup-kubectx-completion() { 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 fi - echo "Setting up completion for $cmd -- $ZSH_COMPLETIONS/_${cmd}" + echo "Setting up completion for $cmd -- $target" local script if [ -f "${dir}/${cmd}.zsh" ]; then @@ -57,8 +58,9 @@ _setup-kubectx-completion() { script="$dir/_${cmd}.zsh" fi + echo " - Sym-linking from $script" mkdir -p "$ZSH_COMPLETIONS" - ln -s "$script" "$ZSH_COMPLETIONS/_${cmd}" + ln -s "$script" "$target" } if command-exists kubectx && ! which _kubectx &> /dev/null; then