Skip to content

Commit 7c4f6ab

Browse files
authored
Add kubernetes current context
Add kubernetes current context
1 parent 44e7bd6 commit 7c4f6ab

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

bash/bashrc.bash

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
HISTSIZE=5000
55
HISTFILESIZE=10000
66
shopt -s histappend
7-
export PROMPT_COMMAND="$PROMPT_COMMAND; history -a"
7+
8+
function add_kubectl_context(){
9+
KUBE_PS1_SYMBOL_IMG=$'\xE2\x98\xB8 '
10+
KUBECTL_CURRENT_CONTENT=$(kubectl config view | grep current-context | sed -e "s|current-context: ||g" | tr -d "\n\r")
11+
PS1="${KUBE_PS1_SYMBOL_IMG}${KUBECTL_CURRENT_CONTENT}$PS1"
12+
}
13+
14+
export PROMPT_COMMAND="${PROMPT_COMMAND:-true}; add_kubectl_context;history -a"
815

916
#Keep your version of the universe
1017
export PATH="$HOME/.local/bin:$HOME/bin:$PATH"
@@ -29,7 +36,6 @@ source /usr/share/fzf/shell/key-bindings.bash
2936

3037
#minikube
3138
source <(minikube completion bash)
32-
alias kubectl='minikube kubectl'
3339

3440
#kubectl
3541
source <(kubectl completion bash)

0 commit comments

Comments
 (0)