title: dynamic background color for custom prompt element in Powerlevel9k
body: <p>I am using the awesome Powerlevel9k theme for my Zsh.</p>
  
  <p>I defined a custom kubecontext element to show my kubernetes cluster (context) and namespace (see code below).</p>
  
  <p>While I conditionally set the foreground color through the color variable I would like to set the background color instead to be able to better see when I work on the production cluster.
  Is that somehow possible with Powerlevel9k? All I could find is that I can set the background color of the prompt element statically with <code>POWERLEVEL9K_CUSTOM_KUBECONTEXT_BACKGROUND='075'</code></p>
  
  <pre><code># Kubernetes Current Context/Namespace
  custom_prompt_kubecontext() {
    local kubectl_version="$(kubectl version --client 2&gt;/dev/null)"
  
    if [[ -n "$kubectl_version" ]]; then
      # Get the current Kuberenetes context
      local cur_ctx=$(kubectl config view -o=jsonpath='{.current-context}')
      cur_namespace="$(kubectl config view -o=jsonpath="{.contexts[?(@.name==\"${cur_ctx}\")].context.namespace}")"
      # If the namespace comes back empty set it default.
      if [[ -z "${cur_namespace}" ]]; then
        cur_namespace="default"
      fi
  
      local k8s_final_text="$cur_ctx/$cur_namespace"
  
      local color='%F{black}'
      [[ $cur_ctx == "prod" ]] &amp;&amp; color='%F{196}'
      echo -n "%{$color%}\U2388  $k8s_final_text%{%f%}" # \U2388 is Kubernetes Icon
  
      #"$1_prompt_segment" "$0" "$2" "magenta" "black" "$k8s_final_text" "KUBERNETES_ICON"
    fi
  }
  
  POWERLEVEL9K_CUSTOM_KUBECONTEXT="custom_prompt_kubecontext"
  
  # Powerlevel9k configuration
  POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir vcs custom_kubecontext)
  </code></pre>
  
  <p>Here is a screenshot of the current setup in action:</p>
  
  <p><a href="https://i.stack.imgur.com/2cAFI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2cAFI.png" alt="screenshot showing the different kubecontext prompt colors depending on the current kubecontext"></a></p>