jonmosco / kube-ps1

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

Turn the prompt on/off on demand #137

Closed tigerpeng2001 closed 2 years ago

tigerpeng2001 commented 3 years ago

The prompt is good when I work with kubectl\, but annoy when I work on something else.

Could you add a wrapper to turn the prompt on and off? My temporary solution is:

HIUSA129273:config-exercise tpeng$ cat ~/.kubep-on
NOKUBEPS1=$PS1
source "/usr/local/opt/kube-ps1/share/kube-ps1.sh"
PS1=$NOKUBEPS1'\n$(kube_ps1) * '
HIUSA129273:config-exercise tpeng$ cat ~/.kubep-off
PS1=${NOKUBEPS1}
HIUSA129273:config-exercise tpeng$ . ~/.kubep-on
HIUSA129273:config-exercise tpeng$ 
(⎈ |fca-ota-admin@fca.ota:graylog) * . ~/.kubep-off
HIUSA129273:config-exercise tpeng$

The solution is broken when I get into my git workspace (with git bash prompt)

HIUSA129273:config-exercise tpeng$ . ~/.kubep-on
HIUSA129273:config-exercise tpeng$ 
(⎈ |fca-ota-admin@fca.ota:graylog) * cd ~/workspace/sandbox/kubespray/
✔ ~/workspace/sandbox/kubespray [master ↓·7|✚ 16…3] 
10:49 $ . ~/.kubep-on
✔ ~/workspace/sandbox/kubespray [master ↓·7|✚ 16…3] 
10:49 $ 
jonmosco commented 3 years ago

The prompt has 2 functions to turn it on and off: kubeon and kubeoff, respectively. See https://github.com/jonmosco/kube-ps1#enablingdisabling

jonmosco commented 2 years ago

Closing issue do to on/off feature being available.

aspain commented 2 years ago

@jonmosco is there a way to have it turned off by default and still be able to use kubeon and kubeoff? Right now, it always defaults to on when I open a new terminal tab

edit: Ah, seems I can just add kubeoff on the next line in my .zshrc file and it will take care of this

credativ-dar commented 1 year ago

kubeoff -g also works to turn it off by default in bash.