Last active
August 17, 2018 20:28
-
-
Save idcrook/52d63f33d038090bd2c3465e19f05223 to your computer and use it in GitHub Desktop.
Shell command line expansion from kubernetes aliases; even complete in system namespace if bash alias uses that
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source kubectl bash completions | |
if hash kubectl 2>/dev/null; then | |
source <(kubectl completion bash) | |
fi | |
# the magic via https://github.com/cykerway/complete-alias | |
# seems to require BASH 4; install bash from Homebrew and make its BASH 4 the default user shell in macOS | |
# mkdir ~/.bash_completion.d | |
# curl -o ~/.bash_completion.d/bash_complete-alias.sh https://raw.githubusercontent.com/cykerway/complete-alias/master/completions/bash_completion.sh | |
if [ -f ~/.bash_completion.d/bash_complete-alias.sh ] ; then | |
. ~/.bash_completion.d/bash_complete-alias.sh | |
fi | |
# in ~/.bash_aliases (that gets sourced by ~/.bashrc) | |
# kubernetes | |
alias kbk="kubectl" | |
alias kbn="kubectl --namespace=kube-system" | |
# _complete_alias requires https://github.com/cykerway/complete-alias to be loaded | |
complete -F _complete_alias kbk | |
complete -F _complete_alias kbn | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To see this in action, you can use the
kubectl
completions on an alias that specifieskube-system
namespace.