kube-ps1: Context and Namespace does not update
Hi! I installed kube-ps1
via Homebrew, unfortunately, the context name and the namespace does not update after switching it.
I need to manually reload my .bash_profile
to update the context and namespace name.
This is the part of me .bash_profile
where I load and configure kube-ps1
:
# kube-ps1
source /usr/local/Cellar/kube-ps1/0.7.0/share/kube-ps1.sh
kubeon -g
KUBE_PS1_SYMBOL_ENABLE=false
KUBE_PS1_NS_ENABLE=true
KUBE_PS1_CTX_COLOR=cyan
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 21 (8 by maintainers)
I think I could solve the problem 🎉
This is my current PS1 configuration (mind the backslash in front of the
$(kube_ps1)
subshell):Once I remove the backslash, the cluster and namespace name is not updated.
I am having exactly the same issue as @tedmiston. None of the pointers in this thread have helped. Updates made via kubectx and kubens do not update the prompt until I open a new shell, or re-source the kube-ps1.sh file.
Edit: If you’re using iTerm2 and its shell integration, that may be the issue. I just reorganised my bashrc and moved the sourcing of the shell integration script below the sourcing of kube-ps1, and now my prompt updates just fine.
Ah yes, the double quotes will only evaluate $PS1 when it is initialized. So your fix to escape the value, or switch to single quotes will get it to work.