Add zsh completions

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-01-10 16:35:58 +00:00
parent 465198f3c8
commit d967d5d603
9 changed files with 101 additions and 126 deletions

View File

@@ -11,6 +11,32 @@
kind
];
programs.zsh.p10k.extraRightPromptElements = [ "kubecontext" ];
programs.zsh = {
initExtra = ''
kubeswitch() {
local target="$HOME/.kube/$1"
local config="$HOME/.kube/config"
if [[ -f "$target" && "$target" != "$config" ]]; then
ln -sf "$target" "$config"
echo "Switched kube context to $1"
p10k reload
else
echo "Invalid kube context: $1"
echo "Ensure the file exists in ~/.kube"
fi
}
_kubeswitch-completion() {
local dir="$HOME/.kube"
local config="$dir/config"
compadd -- ''${(f)"$(find "$dir" -maxdepth 1 \( -type f -o -type l \) -not -name 'config' -exec basename {} \;)"}
}
compdef _kubeswitch-completion kubeswitch
'';
p10k.extraRightPromptElements = [ "kubecontext" ];
};
};
}