add func set_k8s_context and force you to select context, then deal with k8s with that context

This commit is contained in:
hophacker 2020-03-05 16:25:29 +08:00
parent ec6ec688e0
commit 611d712af4
3 changed files with 11 additions and 7 deletions

View File

@ -254,5 +254,4 @@ alias find_large_files="sudo find / -xdev -type f -size +50M"
alias vim_plain="vim -u NONE"
alias edit_alias="vim $yadr_zsh/aliases.zsh $yadr_zsh/functions.zsh -p"
alias docker_purge='docker stop $(docker ps -qa);docker rm $(docker ps -qa)'
alias pzsh='USING_PROXYCHAINS=true proxychains zsh'
alias yarn_sass="SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/ yarn"

View File

@ -237,7 +237,6 @@ function gitcopy() {
fi
}
function kubectl() {
KCONTEXT=${KCONTEXT:-gcloud}
DEBUG=false
finalopts=()
while [[ $@ != "" ]] do
@ -268,7 +267,6 @@ function kubectl() {
command kubectl --kubeconfig=$HOME/.kube/${KCONTEXT}_config $finalopts
}
function stern {
KCONTEXT=${KCONTEXT:-gcloud}
finalopts=()
while [[ $@ != "" ]] do
case $1 in
@ -290,7 +288,6 @@ function stern {
command stern $finalopts -t --since 10m --kubeconfig=$HOME/.kube/${KCONTEXT}_config
}
function helm() {
KCONTEXT=${KCONTEXT:-gcloud}
DEBUG=false
finalopts=()
while [[ $@ != "" ]] do
@ -324,7 +321,6 @@ function helm() {
}
function kexec {
RAN=false
KCONTEXT=${KCONTEXT:-gcloud}
NAMESPACE=default
finalopts=()
while [[ $@ != "" ]] do
@ -408,7 +404,6 @@ function kexec {
}
function klogs {
KCONTEXT=${KCONTEXT:-gcloud}
finalopts=()
while [[ $@ != "" ]] do
case $1 in

View File

@ -70,10 +70,20 @@ function prompt_skwp_setup {
zstyle ':prezto:module:ruby:info:version' format '[%v]'
PROMPT="${__PROMPT_SKWP_COLORS[3]}%n%f ${__PROMPT_SKWP_COLORS[5]}%~%f "'$git_info[prompt]'"$ "
[[ $USING_PROXYCHAINS == 'true' ]] && PROMPT="🔗 $PROMPT"
[[ "$KCONTEXT" != "" ]] && PROMPT="%F{blue}$KCONTEXT💡 $PROMPT"
RPROMPT='%F{blue}${ruby_info[version]}'
}
alias disable_git_info='DISABLE_GIT_INFO=1'
alias enable_git_info='DISABLE_GIT_INFO=0'
function set_k8s_context {
C=$1
if [[ "$C" == "" ]]; then
echo "Select your context:"
ls ~/.kube/*_config | xargs -n 1 basename | sed s/_config//g
read C
fi
export KCONTEXT=$C
prompt_skwp_setup
}
prompt_skwp_setup "$@"