-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathk8s-git-ps1
More file actions
27 lines (20 loc) · 926 Bytes
/
k8s-git-ps1
File metadata and controls
27 lines (20 loc) · 926 Bytes
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
##############################
## Prompt ps1 k8s + git
##############################
function k8s_git_ps1_prompt {
local __time="\[\033[32m\][\D{%H:%M}] "
local __cur_location="\[\033[00m\]\w "
local __git_branch_color="\[\033[1;32m\]"
local __git_branch='`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\/`'
local __k8s_ns='`kubectl config view --minify --output jsonpath={..namespace} 2> /dev/null`'
local __k8s_context=`kubectl config view --minify --output jsonpath={.current-context} 2> /dev/null`
local __k8s_info="\[\033[1;36m\][$__k8s_context:$__k8s_ns] "
local __k8s_info="\[\033[1;36m\][$__k8s_context:$__k8s_ns] "
local __symbol_arrow="\[\033[00m\]$ "
PS1="$__time"
PS1+="$__k8s_info"
PS1+="$__cur_location"
PS1+="$__git_branch_color$__git_branch\n"
PS1+="$__symbol_arrow"
export PS1
}; k8s_git_ps1_prompt