Diff
1diff --git a/plugins/kube-ps1/README.md b/plugins/kube-ps1/README.md
2index fcb73cd2d5afc67f42e1494c233363c74ee2967e..19dac42e9c27e74f459fb422cac7e6f5d965da62 100644
3--- a/plugins/kube-ps1/README.md
4+++ b/plugins/kube-ps1/README.md
5@@ -45,20 +45,37 @@ want to load.
6 vim $HOME/.zshrc
7 ```
8
9-Add kube-ps1 to the list of enabled plugins:
10+Add kube-ps1 to the list of enabled plugins and enable it on the prompt:
11
12 ```shell
13 plugins=(
14 git
15 kube-ps1
16 )
17+
18+PROMPT=$PROMPT'$(kube_ps1) '
19+```
20+
21+Note: the `PROMPT` example above was tested with the theme `robbyrussell`
22+
23+## Enabling / Disabling on the current shell
24+
25+Sometimes the kubernetes information can be anoying, you can easily
26+switch it on and off with the following commands:
27+
28+```shell
29+kubeon
30+```
31+
32+```shell
33+kubeoff
34 ```
35
36 ## Colors
37
38 Blue was used as the prefix to match the Kubernetes color as closely as
39 possible. Red was chosen as the cluster name to stand out, and cyan
40-for the namespace. These can of course be changed.
41+for the namespace. Check the customization section for changing them.
42
43 ## Customization
44
45@@ -75,7 +92,12 @@ The default settings can be overridden in ~/.zshrc
46 | `KUBE_PS1_SEPERATOR` | `\|` | Separator between symbol and cluster name |
47 | `KUBE_PS1_DIVIDER` | `:` | Separator between cluster and namespace |
48 | `KUBE_PS1_SUFFIX` | `)` | Prompt closing character |
49+| `KUBE_PS1_COLOR_SYMBOL` | `"%F{blue}"` | Custom color for the symbol |
50+| `KUBE_PS1_COLOR_CONTEXT` | `"%F{red}"` | Custom color for the context |
51+| `KUBE_PS1_COLOR_NS` | `"%F{cyan}"` | Custom color for the namespace |
52+| `KUBE_PS1_ENABLED` | `true` | Set to false to start disabled on any new shell, `kubeon`/`kubeoff` will flip this value on the current shell |
53
54 ## Contributors
55
56-Jared Yanovich
57+- Jared Yanovich
58+- Pedro Moranga
59diff --git a/plugins/kube-ps1/kube-ps1.plugin.zsh b/plugins/kube-ps1/kube-ps1.plugin.zsh
60index df7277a26fb2bf2abb5bd1e0b84cf63f00b88a62..8a751bda897e1530ecb3a83d806216d53a59e1a2 100644
61--- a/plugins/kube-ps1/kube-ps1.plugin.zsh
62+++ b/plugins/kube-ps1/kube-ps1.plugin.zsh
63@@ -39,6 +39,11 @@ KUBE_PS1_DIVIDER="${KUBE_PS1_DIVIDER-:}"
64 KUBE_PS1_PREFIX="${KUBE_PS1_PREFIX-(}"
65 KUBE_PS1_SUFFIX="${KUBE_PS1_SUFFIX-)}"
66 KUBE_PS1_LAST_TIME=0
67+KUBE_PS1_ENABLED=true
68+
69+KUBE_PS1_COLOR_SYMBOL="%F{blue}"
70+KUBE_PS1_COLOR_CONTEXT="%F{red}"
71+KUBE_PS1_COLOR_NS="%F{cyan}"
72
73 _kube_ps1_binary_check() {
74 command -v "$1" >/dev/null
75@@ -127,21 +132,28 @@ _kube_ps1_get_context_ns() {
76 fi
77 }
78
79+# function to disable the prompt on the current shell
80+kubeon(){
81+ KUBE_PS1_ENABLED=true
82+}
83+
84+# function to disable the prompt on the current shell
85+kubeoff(){
86+ KUBE_PS1_ENABLED=false
87+}
88+
89 # Build our prompt
90 kube_ps1 () {
91- local reset_color="%f"
92- local blue="%F{blue}"
93- local red="%F{red}"
94- local cyan="%F{cyan}"
95+ local reset_color="%{$reset_color%}"
96+ [[ ${KUBE_PS1_ENABLED} != 'true' ]] && return
97
98 KUBE_PS1="${reset_color}$KUBE_PS1_PREFIX"
99- KUBE_PS1+="${blue}$(_kube_ps1_symbol)"
100+ KUBE_PS1+="${KUBE_PS1_COLOR_SYMBOL}$(_kube_ps1_symbol)"
101 KUBE_PS1+="${reset_color}$KUBE_PS1_SEPERATOR"
102- KUBE_PS1+="${red}$KUBE_PS1_CONTEXT${reset_color}"
103+ KUBE_PS1+="${KUBE_PS1_COLOR_CONTEXT}$KUBE_PS1_CONTEXT${reset_color}"
104 KUBE_PS1+="$KUBE_PS1_DIVIDER"
105- KUBE_PS1+="${cyan}$KUBE_PS1_NAMESPACE${reset_color}"
106+ KUBE_PS1+="${KUBE_PS1_COLOR_NS}$KUBE_PS1_NAMESPACE${reset_color}"
107 KUBE_PS1+="$KUBE_PS1_SUFFIX"
108
109 echo "${KUBE_PS1}"
110-
111 }