Powerlevel9k / powerlevel9k

Powerlevel9k was a tool for building a beautiful and highly functional CLI, customized for you. P9k had a substantial impact on CLI UX, and its legacy is now continued by P10k.
https://github.com/romkatv/powerlevel10k
MIT License
13.46k stars 946 forks source link

Cannot Add custom_command on Left Elements #1325

Closed fauzan-n closed 5 years ago

fauzan-n commented 5 years ago

How to reproduce : Add this configuration to .zshrc

POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir vcsi custom_kubernetes_contexts)
POWERLEVEL9K_CUSTOM_KUBERNETES_CONTEXTS=(kubectl config get-contexts | grep '*' | awk '{print $2}')

Result expectation : Showing kubernetes cluster name

Result reality : .zshrc:15: parse error near|'`

romkatv commented 5 years ago

What are you trying to achieve? If you want to display your current kubernetes context, you can use kubecontext prompt segment. Try this:

POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(kubecontext)

# Don't show trailing "/default" in kubernetes context.
POWERLEVEL9K_KUBECONTEXT_SHOW_DEFAULT_NAMESPACE=false

# Kubernetes context classes for the purpose of using different colors with different contexts.
#
# POWERLEVEL9K_KUBECONTEXT_CLASSES is an array with even number of elements. The first element in
# each pair defines a pattern against which the current kubernetes context (in the format it is
# displayed in the prompt) gets matched. The second element defines the context class. Patterns
# are tried in order. The first match wins.
#
# For example, if your current kubernetes context is "deathray-testing", its class is TEST because
# "deathray-testing" doesn't match the pattern '*prod*' but does match '*test*'. Hence it'll be
# shown with the background color of $POWERLEVEL9K_KUBECONTEXT_TEST_BACKGROUND.
POWERLEVEL9K_KUBECONTEXT_CLASSES=(
    '*prod*'  PROD
    '*test*'  TEST
    '*'       DEFAULT)

POWERLEVEL9K_KUBECONTEXT_PROD_BACKGROUND=1
POWERLEVEL9K_KUBECONTEXT_TEST_BACKGROUND=2
POWERLEVEL9K_KUBECONTEXT_DEFAULT_BACKGROUND=3

Does it do what you want?

P.S.

You have vcsi in POWERLEVEL9K_LEFT_PROMPT_ELEMENTS but there is no such segment. Did you mean vcs?

romkatv commented 5 years ago

Sorry, I thought this issue was open against another github project. Powerlevel9k doesn't have the POWERLEVEL9K_KUBECONTEXT_* options I mentioned. It does have POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(kubecontext) though.

fauzan-n commented 5 years ago

@romkatv Thanks That is what i'm lookin for

and yes i'm typo about vcsi , it should be vcs