jonmosco / kube-ps1

Kubernetes prompt info for bash and zsh
Apache License 2.0
3.52k stars 351 forks source link

Promt not reloaded after context change #143

Closed beatsandpics closed 2 years ago

beatsandpics commented 2 years ago

When I change the context with kubectx or kubens, the promt no longer get's updated. When I restart my shell it's updated

(⎈ |inova-saas:inova) ~  kubectx
Switched to context "tsm-db2020".
(⎈ |inova-saas:inova) ~  zsh
(⎈ |tsm-db2020:ingress-nginx) ~ 

With Debug on ( here from simap-dev to fity-k8s-cloud )


(⎈ |simap-dev:dev) ~  zsh -f
Marcs-iMac% source /usr/local/opt/kube-ps1/share/kube-ps1.sh
Marcs-iMac% export PS1='$(kube_ps1)'$PS1
(⎈ |simap-dev:dev)Marcs-iMac% kubectx
Switched to context "fity-k8s-cloud".
(⎈ |simap-dev:dev)Marcs-iMac% export DEBUG=true
(⎈ |simap-dev:dev)Marcs-iMac% kubectx
+ set -eou pipefail
+ IFS='
    '
+ SELF_CMD=/usr/local/bin/kubectx
+ KUBECTX=/Users/marc/.kube/kubectx
+ main
+ [[ -z '' ]]
+ hash kubectl
+ KUBECTL=kubectl
+ [[ 0 -eq 0 ]]
+ [[ -t 1 ]]
+ [[ -z '' ]]
++ type fzf
++ echo 0
+ [[ 0 -eq 0 ]]
+ choose_context_interactive
+ local choice
++ _KUBECTX_FORCE_COLOR=1
++ FZF_DEFAULT_COMMAND=/usr/local/bin/kubectx
++ fzf --ansi --no-preview
+ choice=inova-saas
+ [[ -z inova-saas ]]
+ set_context inova-saas
+ local prev
++ current_context
++ kubectl config view '-o=jsonpath={.current-context}'
+ prev=bgs-shared
+ switch_context inova-saas
+ kubectl config use-context inova-saas
Switched to context "inova-saas".
+ [[ bgs-shared != \i\n\o\v\a\-\s\a\a\s ]]
+ save_context bgs-shared
+ local saved
++ read_context
++ [[ -f /Users/marc/.kube/kubectx ]]
++ cat /Users/marc/.kube/kubectx
+ saved=fity-k8s-cloud
+ [[ fity-k8s-cloud != \b\g\s\-\s\h\a\r\e\d ]]
+ printf %s bgs-shared```
beatsandpics commented 2 years ago

Some more information

Mac OS X 11.6
zsh 5.8 (x86_64-apple-darwin20.0)
jonmosco commented 2 years ago

It looks like a shell configuration issue with the way it is sourced. Can you try it without your current zsh config? Instructions for that are in the README.

jonmosco commented 2 years ago

This is a configuration issue. Closing.