Repository navigation
Expand file tree
/
Copy path.bashrc.vpnachev
More file actions
158 lines (130 loc) · 5.2 KB
/
Copy path.bashrc.vpnachev
File metadata and controls
158 lines (130 loc) · 5.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
GOROOT="/usr/local/go"
export GOPATH="${HOME}/go"
export PATH="/sbin:/usr/sbin:/usr/local/sbin:${PATH}:${GOPATH}/bin:${GOROOT}/bin"
export Videos="/var/lib/Videos"
export LANG=en_US.UTF-8
export DOCKER_BUILDKIT=1
# Enable the recommended auth mechanism for GKE kubeconfigs: https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke
export USE_GKE_GCLOUD_AUTH_PLUGIN=True
# k8s.io cherry-pick env
export GITHUB_USER=vpnachev
export UPSTREAM_REMOTE=origin
export FORK_REMOTE=vpnachev
# 29 for black, 31 red
#export PS1="\[\033[01;31m\]\[$(ppwd)\]\u@\h:\w\[\033[0m\]\n> "
#export PS1='• \[\e[0;32m\]\u@\H\[\e[m\]•\[\e[1;34m\] \w \[\e[m\]• \n• '
## powerline-shell https://github.com/b-ryan/powerline-shell
function _update_ps1() {
local ext_code=$?
export KUBE_PS_CONTEXT="$(kubectl config current-context 2>/dev/null)"
KUBE_PS_NAMESPACE="$(kubectl config view --minify --output jsonpath="{.contexts[?(@.name == \"$KUBE_PS_CONTEXT\")].context.namespace}" 2>/dev/null)"
KUBE_PS_NAMESPACE="${KUBE_PS_NAMESPACE:-default}"
if [[ $KUBE_PS_CONTEXT == "" ]]
then
KUBE_PS_NAMESPACE=""
fi
export KUBE_PS_NAMESPACE
PS1=$(powerline-shell $ext_code)
}
if [[ $TERM != linux && ! $PROMPT_COMMAND =~ _update_ps1 ]]; then
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi
function _disable_kubectx_prompt() {
export KUBECONFIG=/invalid/path/to/kubeconfig
}
function _enable_kubectx_prompt() {
unset KUBECONFIG #return it to default behaviour
}
## powerline END
_completion_dir=$HOME/.completion.d/bash
mkdir -p ${_completion_dir}
KUBECTL_VERSION=$(cat ${_completion_dir}/kubectl.version 2>/dev/null)
HELM_VERSION=$(cat ${_completion_dir}/helm.version 2>/dev/null)
KIND_VERSION=$(cat ${_completion_dir}/kind.version 2>/dev/null)
COSIGN_VERSION=$(cat ${_completion_dir}/cosign.version 2>/dev/null)
KUBECTL_V=$(kubectl version --client -o json | jq .clientVersion.gitVersion -r)
HELM_V=$(helm version --client --short | grep -o "v[0-9].*[0-9]")
KIND_V=$(kind version -q)
COSIGN_V=$(cosign version --json 2>&1 | jq .gitVersion -cr)
if [[ x${KUBECTL_VERSION}x != x${KUBECTL_V}x ]]; then
echo -n $KUBECTL_V > ${_completion_dir}/kubectl.version
kubectl completion bash >${_completion_dir}/kubectl
fi
if [[ x${HELM_VERSION}x != x${HELM_V}x ]]; then
echo -n $HELM_V > ${_completion_dir}/helm.version
helm completion bash >${_completion_dir}/helm
fi
if [[ x${KIND_VERSION}x != x${KIND_V}x ]]; then
echo -n $KIND_V > ${_completion_dir}/kind.version
kind completion bash >${_completion_dir}/kind
fi
if [[ x${COSIGN_VERSION}x != x${COSIGN_V}x ]]; then
echo -n $COSIGN_V > ${_completion_dir}/cosign.version
cosign completion bash >${_completion_dir}/cosign
fi
alias xpaste="xclip -sel col -o"
alias xcopy="xclip -sel col"
alias temperature="sensors|grep '^Core.*?°C' -P"
alias k='kubectl'
alias kall='kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get --no-headers --show-kind --ignore-not-found -n '
alias ks='kubectl -n kube-system '
alias kg='kubectl -n garden '
alias kchroot='kubectl exec -it -f /home/I311840/pr-pod.yaml -- chroot /host'
alias kctx="kubectx"
alias kns="kubens"
alias цд="cd"
alias лс="ls"
alias лл="ll"
alias пвд="pwd"
alias gk='_gardener_kconfig'
alias diff='diff --color=always'
alias watch='watch -d -c '
alias cds="cd $GOPATH/src/"
alias cdg="cd $GOPATH/src/github.com/gardener/"
alias cdgg="cd $GOPATH/src/github.com/gardener/gardener"
alias cdgl="cd $HOME/Documents/git/gardenlinux/gardenlinux/"
alias weather="curl wttr.in"
complete -o default -F __start_kubectl k
complete -o default -F __start_kubectl ks
complete -o default -F __start_kubectl kg
complete -o default -F __start_gardenctl g
complete -C '/usr/local/bin/aws_completer' aws
complete -C /usr/local/bin/aliyun aliyun
test -s ${_completion_dir}/kubectl && source ${_completion_dir}/kubectl
test -s ${_completion_dir}/helm && source ${_completion_dir}/helm
test -s ${_completion_dir}/kind && source ${_completion_dir}/kind
test -s ${_completion_dir}/kubectx.bash && source ${_completion_dir}/kubectx.bash
test -s ${_completion_dir}/kubens.bash && source ${_completion_dir}/kubens.bash
test -s ${_completion_dir}/cosign && source ${_completion_dir}/cosign
function kconfig {
export KUBECONFIG=$(readlink -f $1)
}
# credits for the jwks token decoding: mvladev
decode_base64_url() {
local len=$((${#1} % 4))
local result="$1"
if [ $len -eq 2 ]; then result="$1"'=='
elif [ $len -eq 3 ]; then result="$1"'='
fi
echo "$result" | tr '_-' '/+' | base64 -d
}
decode_jose(){
decode_base64_url $(echo -n $2 | cut -d "." -f $1) | jq .
}
decode_jwt_part(){
decode_jose $1 $2 | jq 'if .iat then (.iatStr = (.iat|todate)) else . end | if .exp then (.expStr = (.exp|todate)) else . end | if .nbf then (.nbfStr = (.nbf|todate)) else . end'
}
decode_jwt(){
decode_jwt_part 1 $1
decode_jwt_part 2 $1
}
# Decode JWT header
alias jwth="decode_jwt_part 1"
# Decode JWT Payload
alias jwtp="decode_jwt_part 2"
# Decode JWT header and payload
alias jwthp="decode_jwt"
alias kjwthp="show_kubectl_id_token"
function show_kubectl_id_token {
jwthp $(kubectl config view --minify -o jsonpath="{.users[0].user.auth-provider.config.id-token}")
}