Closed BMouser closed 3 years ago
This should work:
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
dir vcs kubecontext newline
time kubecontext prompt_char
)
POWERLEVEL9K_TRANSIENT_PROMPT=off
function p10k-on-pre-prompt() {
p10k display '(1|/right/*)'=show '2/left/time'=hide
}
function p10k-on-post-prompt() {
local -a reply
p10k display -a '1/left/kubecontext'
p10k display '(1|/right/*)'=hide '2/left/time'=show '2/left/kubecontext'=$reply[2]
}
function p10k-on-post-widget() {
p10k display '2/left/kubecontext'=hide
}
p10k-on-post-widget
hides kubecontext
on the second prompt line so that you never have two instances displayed at once. p10k-on-post-prompt
copies the display status from kubecontext
on the first line to the one on the second.
Thanks Roman for the response. I had tried something similar but was misusing the reply array API. I'll incorporate this into my config.
I've only just started using p10k in the last week and so far am quite happy with the tool. I was curious though if there was a better way to have a
kubecontext
that behaves as the picture below:The key pieces from that picture are:
So far I have been able to do this by using the API described in https://github.com/romkatv/powerlevel10k/issues/318#issuecomment-573445060 as well as forking the powerlevel10k project and copying the built-in kubecontext prompt (https://github.com/BMouser/powerlevel10k/commit/6af165b2b47b76096db0af57445d2bd397418677 Note: that this is not at all a pull request. I do not believe my duplication should be made to the main project). With this setup I ended up with a p10k config similar to:
What I have "works" but isn't exactly elegant and I was curious if I had another option. I did see the original gist you created https://gist.github.com/romkatv/33f02f42245967072f8d00fc1db0f7fc but had wanted to try and keep the main and transient prompt configuration as similar as possible to avoid oddities.
Edit: I realized the picture had the same-dir like behavior so added that config back to my
p10k-on-post-prompt
to avoid potential confusion.