-
Notifications
You must be signed in to change notification settings - Fork 947
[kubecontext] Add possibility to on/off segment with commands #1252
Comments
i don't know nothing about kubcontext (what htis is about ?). But i'm thinking that you can do the change and post a ull request for that. |
@jerome-diver thanks :) I would need help with review for sure. But first I would like to hear what @bhilburn thinks about the idea I presented. |
I think similar snippet can be used as in #1220 but which will test the presence of a variable. |
Hi @grzesuav , I think this would be a cool addition. If you want to implement such change, please do it on top of the About your idea: Are there other things that happen (like a variable being set, or a lockfile being written), if you do a Edit: |
@dritter My intention is to do it in active way - I have cluster connectivity set all the time (there is no time when my context is no present like in #1220) - I just do not want to see it all the time, because I do not work with it all the time. So Only passive way how it can be done (which I can think of) is just to commit code checking if some variable is present, keeping aliases for setting this variable outside. But then anyone who would like to use this variable would need to create this aliases on its own (which is also ok for me). Is it ok ? @jerome-diver thanks, planning to do something similar :) |
Perhaps there should be a general mechanism to disable/enable a prompt segment? E.g., if Then kubeon() { P9K_KUBECONTEXT_DISABLED=0 }
kubeoff() { P9K_KUBECONTEXT_DISABLED=1 } |
I cannot say if this would be useful mechanism in general, for sure it fits for working with |
@grzesuav My suggestion/question was primarily directed towards @dritter. My role on p9k is limited to observation. However, I do care about the new features that get implemented in p9k as I'm obligated to pull them to Powerlevel10k. Since implementing on/off switch just for kubecontext is the same amount of work and complexity as implementing it for all segments, future and present, I'd very much prefer the generic solution. It'll work for every feature request of similar nature and will keep overall complexity of the implementation, API surface and configuration space down. |
@romkatv ok, understood ;) If it is worth to be generalized, we can try to do it but this is my very beginning working with powerlevel code so I will feel more comfortable to do small change first, and then generalize if needed. |
Ok thanks guys ! Will try to implement something and push next week |
(Sorry if i'm rehashing this) tl;dr - If your using an alias to unset a env variable to turn off the segment, will you still use kubectl while the segment is off generally? Is there a benefit to turning this on and off in this way rather than unsetting your $KUBECONFIG itself? PR #1220 will fix the prompt so that if there is no context (or not kubeconfig set) it will hide itself, which I think it the best behavior as the prompt is then reflecting what your "pointing" or configured to talk to. (i.e. Segment hides when kubectl is not configured to talk to anything, but shows up when you are) I assume this would allow us to do something like unset $KUBECONFIG and it will hide the prompt, then set it again and it would show up. I use aliases/functions to switch it back and forth to different configuration files as needed so i'm usually setting/unsetting KUBECONFIG anyway. Not sure if that is common practice though? |
|
Ah, okay I see. So when you interact with k8s you would do something like ‘kubectl —kubeconfig=’ type thing then? Sorry for off topic question, I’m still learning k8s myself. |
@Thutm No, I don't. By default |
Add generic mechanism to disable segment when flag $POWERLEVEL9K_segmend_DISABLED is set to "1"
Hi, taken longer that I expected, but I did a POC - #1359 it seems it is working, I have tested it locally |
I just realize that I did changes against master branch, I tried to rebase on |
Add generic mechanism to disable segment when flag $P9K_segment_name_DISABLED is set to "1"
@jerome-diver @romkatv @dritter got time and figured it up . Updated PR against Can you take a look ? |
Took a look. Should work. Since this issue has been opened, I've learned of a better solution. Or rather two complementary solutions. The first is to display kubernetes context only when the current command you are typing is |
@romkatv nice to know. Could you point to some resource about it ? I think in general this PR can be useful outside a context of kubectl (as it is generic) but I curious in general :) |
I'm afraid this would violate p9k code of conduct.
Indeed. As I mentioned earlier, I have no power to reject or accept p9k PRs. I'm just a ghost haunting an abandoned castle. |
It would be great to have possibility to customize
kubcontext
behavior with on/off switch.It would require changes around https://github.com/bhilburn/powerlevel9k/blob/master/powerlevel9k.zsh-theme#L1694 :
kubeon
/kubeoff
probably fit the best)I am aware of #860 but I thinking about extending current segment.
What do you think about idea ? Does it have any drawbacks (i.e. is it impossible for segment to display "nothing") ?
I can try to implement this idea (need help with variable naming tough).
Cheers
The text was updated successfully, but these errors were encountered: