forked from tpounds/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc.kubernetes
39 lines (34 loc) · 896 Bytes
/
.zshrc.kubernetes
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
# helm completions
command -v helm >/dev/null 2>&1 && {
source <(helm completion zsh)
}
# kind completions
command -v kind >/dev/null 2>&1 && {
source <(kind completion zsh)
compdef _kind kind
}
# kompose completions
command -v kompose >/dev/null 2>&1 && {
source <(kompose completion zsh)
}
# kubectl aliases/completions
command -v kubectl >/dev/null 2>&1 && {
alias k='kubectl'
source <(kubectl completion zsh)
}
# Create prompt with current kubectl context/namespace.
precmd_kubeps1() {
KUBEPS1=$(kubectl config get-contexts 2>/dev/null | awk '
/^\*/ {
name=$2
cluster=$3
authinfo=$4
namespace=$5
if (length($5) == 0) {
namespace="default"
}
printf "%%B%%F{63}☸%%f%%b%%F{186}%s%%f:%%F{131}%s%%f", cluster, namespace
}
')
}
precmd_functions=($precmd_functions precmd_kubeps1)