Files
nix/hosts/common/configs/user/console/kubernetes/default.nix
Nikolaos Karaolidis d967d5d603 Add zsh completions
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
2025-01-10 16:35:58 +00:00

43 lines
1.0 KiB
Nix

{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ pkgs, ... }:
{
home-manager.users.${user} = {
home.packages = with pkgs; [
kubectl
kubernetes-helm
kind
];
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" ];
};
};
}