chore: set up bash completion and kubectl completion. fix small mac issue

pull/7/head
Adam Veldhousen 3 years ago
parent 1209b6e8f1
commit 16a5456fd7
Signed by: adam
GPG Key ID: 6DB29003C6DD1E4B

@ -11,4 +11,6 @@ fi
[[ -f "${LINUX_BREW_PATH}/bin/brew" ]] && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)";
[[ -f "$(brew --prefix bash-completion)/etc/bash_completion" ]] || brew install bash-completion
source "$(brew --prefix bash-completion)/etc/bash_completion";

@ -1,15 +1,11 @@
#!/bin/env bash
if [[ -f "$(which kubectl)" ]]; then
__KUBECTL_COMPLETION_FILE="${ZSH_CACHE_DIR}/kubectl_completion"
if [[ ! -f $__KUBECTL_COMPLETION_FILE || ! -s $__KUBECTL_COMPLETION_FILE ]]; then
kubectl completion zsh >! $__KUBECTL_COMPLETION_FILE
fi
[[ -f $__KUBECTL_COMPLETION_FILE ]] && source $__KUBECTL_COMPLETION_FILE
if [[ -f "$(which brew 2>&1)" ]]; then
brew install kubectl;
fi
unset __KUBECTL_COMPLETION_FILE
if [[ -f "$(which kubectl)" ]] && [[ -d "$(brew --prefix bash-completion)/etc/bash_completion.d" ]]; then
kubectl completion bash > "$(brew --prefix bash-completion)/etc/bash_completion.d/kubectl";
fi
# This command is used a LOT both below and in daily life
@ -176,7 +172,8 @@ if (( ${+_comps[kubectl]} )); then
kjx() { kubectl "$@" -o json | fx; }
ky() { kubectl "$@" -o yaml | yh; }
compdef kj=kubectl
compdef kjx=kubectl
compdef ky=kubectl
# this stuff fails on OSX
# compdef kj=kubectl
# compdef kjx=kubectl
# compdef ky=kubectl
fi

Loading…
Cancel
Save