Add kubectl wrapper for convenience and safety

This commit is contained in:
Daniel Lundin 2020-08-21 09:09:08 +02:00
parent fff0b0016f
commit 1765917dba
No known key found for this signature in database
GPG key ID: 6AB527C9196ACDCC
2 changed files with 10 additions and 0 deletions

1
.zshrc
View file

@ -259,6 +259,7 @@ alias ag='ag --pager less'
alias cdiff='colordiff -u'
alias dotgit='git --work-tree $HOME --git-dir $HOME/.dot_git'
alias hs='history -a; history -n'
alias kubectl='kubectl-wrapper'
alias lower="tr '[:upper:]' '[:lower:]'"
alias pstree="pstree -Auh | less"
alias tail='tail -n $LINES'

9
bin/kubectl-wrapper Executable file
View file

@ -0,0 +1,9 @@
#!/bin/bash
cfg=.kubeconfig
path=$(pwd)
while [[ "$path" != "" && ! -e "$path/$cfg" ]]; do
path=${path%/*}
done
exec env KUBECONFIG="$path/$cfg:$KUBECONFIG:$HOME/.kube/config" kubectl "$@"