DEV Community

Vinicius
Vinicius

Posted on • Updated on

Disable Kubecontext (namespace) display on Powerlevel ZSH Theme

Just give me the solution right away!!!

In order to disable Kubecontext (namespace) display on Powerlevel ZSH Theme, just comment out or remove the kubecontext declaration around line 67 in your current /Users/$yourusername/.p10k.zsh script. Example:

  typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
  ...
  # kubecontext # current kubernetes context (https://kubernetes.io/)
  ...
  )
Enter fullscreen mode Exit fullscreen mode

Restart your terminal and notice the missing kubernetes Kubecontext (namespace) info on your terminal session.

Introduction

I've a regular Oh My ZSH user for a few weeks and often times, I try to test new plugins or themes and today (Nov 25) i've came across the Powerlevel ZSH Theme.

I found it so cool that I decided to give it a try, but after finishing the installation process, the terminal was displaying the Kubernetes Kubecontext (namespace) info, which I strongly want to remove it.

Powerlevel ZSH Theme Kubernetes Kubecontext

The Problem

After going thru the installation one more time (the whole process is managed by a Next, Next, Finish Terminal like experience), I've noticed that Kubernetes namespace was displayed. Thus, i've decided to double check if there's any Kubernetes related configuration section which I've missed, however, unfortunately the installer offers no feature to change this behaviour.

After googleing a little bit about this issue, I've found some open issues (860 , 1252) on github to address this problem, however no solution was pointed out.

With that said, i thought it was something related to others Oh My ZSH plugins such as kube-ps1 or some miss configuration on my side, which was not the case.

Since I couldn't find anything that could shade some light on this issue, reviewing ZSH configuration /Users/$yourusername/.zshrc was my next choice and luckily I've found this:

  # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
  [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
Enter fullscreen mode Exit fullscreen mode

Fixing the Problem

The p10k.zsh script performs all heavy-lifting for Powerlevel ZSH Theme, therefore, all configurations, extensions and customisations should be available within it.

Thus, I've spent some minuted reviewing it's source code and came across this snippet:

  typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
  ...
  kubecontext # current kubernetes context (https://kubernetes.io/)
  ...
  )
Enter fullscreen mode Exit fullscreen mode

After commenting out kubecontext declaration from the above snippet, finally the kubernetes Kubecontext (namespace) no longer came out.

Powerlevel ZSH Theme Kubernetes Without Kubecontext

Top comments (0)