mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 13:46:41 +00:00
fix(kubernetes): resolve shell completion setup for kubectl and krew
This commit is contained in:
@@ -3,17 +3,25 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
alias kc="kubectl"
|
alias kc="kubectl"
|
||||||
|
alias kx="kubectx"
|
||||||
|
alias kn="kubens"
|
||||||
alias hl="helm"
|
alias hl="helm"
|
||||||
alias mk="minikube"
|
alias mk="minikube"
|
||||||
alias kctx="kubectx"
|
|
||||||
alias kns="kubens"
|
|
||||||
|
|
||||||
if command-exists kubectl; then
|
if command-exists kubectl; then
|
||||||
# lazy-load kubectl completion
|
_setup-kubectl-completion() {
|
||||||
_kubectl() {
|
local target
|
||||||
unset -f _kubectl
|
target="$ZSH_COMPLETIONS/_kubectl"
|
||||||
eval "$(command kubectl completion zsh)"
|
|
||||||
|
if [ ! -f "$target" ] || [ "$target" -ot "$(command -v kubectl)" ]; then
|
||||||
|
echo "Setting up completion for kubectl -- $target"
|
||||||
|
mkdir -p "$ZSH_COMPLETIONS"
|
||||||
|
kubectl completion zsh > "$target"
|
||||||
|
chmod +x "$target"
|
||||||
|
autoload -U compinit && compinit
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
_setup-kubectl-completion
|
||||||
|
|
||||||
switch() {
|
switch() {
|
||||||
unset -f switch
|
unset -f switch
|
||||||
@@ -25,14 +33,14 @@ if command-exists kubectl; then
|
|||||||
path_append "${KREW_ROOT}/bin"
|
path_append "${KREW_ROOT}/bin"
|
||||||
|
|
||||||
if ! command-exists kubectl-krew; then
|
if ! command-exists kubectl-krew; then
|
||||||
krew-bin() {
|
krew-bin-name() {
|
||||||
echo "krew-$(uname | tr '[:upper:]' '[:lower:]')_$(uname -m | sed -e \
|
echo "krew-$(uname | tr '[:upper:]' '[:lower:]')_$(uname -m | sed -e \
|
||||||
's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' \
|
's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' \
|
||||||
-e 's/aarch64$/arm64/')"
|
-e 's/aarch64$/arm64/')"
|
||||||
}
|
}
|
||||||
|
|
||||||
zinit light-mode wait lucid as'null' from'gh-r' bpick'krew.tar.gz' \
|
zinit light-mode wait lucid as'null' from'gh-r' bpick"$(krew-bin-name)*" \
|
||||||
atclone'KREW='"'$(krew-bin)'"' && ./$KREW install krew' \
|
atclone'KREW='"'$(krew-bin-name)'"' && ./$KREW install krew' \
|
||||||
for @kubernetes-sigs/krew
|
for @kubernetes-sigs/krew
|
||||||
|
|
||||||
export KREW_ROOT="$HOME/.krew"
|
export KREW_ROOT="$HOME/.krew"
|
||||||
@@ -61,6 +69,7 @@ _setup-kubectx-completion() {
|
|||||||
echo " - Sym-linking from $script"
|
echo " - Sym-linking from $script"
|
||||||
mkdir -p "$ZSH_COMPLETIONS"
|
mkdir -p "$ZSH_COMPLETIONS"
|
||||||
ln -s "$script" "$target"
|
ln -s "$script" "$target"
|
||||||
|
autoload -U compinit && compinit
|
||||||
}
|
}
|
||||||
|
|
||||||
if command-exists kubectx && ! which _kubectx &> /dev/null; then
|
if command-exists kubectx && ! which _kubectx &> /dev/null; then
|
||||||
|
|||||||
Reference in New Issue
Block a user