Add zsh completions
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -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" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user