kubernetes - How to show cmd at each ZSH shell line? -


i have function in zsh configuration :

local kube_prompt()  {    kubectl_current_context=$(kubectl config current-context)    kubectl_cluster=$(echo $kubectl_current_context | cut -d '_' -f 4)    kubectl_prompt="⎈ ($kubectl_cluster)"    echo $kubectl_prompt } 

and call way :

%{$fg[white]%}$(kube_prompt) \ ${git_info} \ 

it work (i have output on shell prompt) problem is,

i want command launch @ each shell line (when press enter example) , not when open new shell.

any idea how achieve ?

thanks !!!

you can add delay evaluation of function adding single quotes around it.

i.e. prompt should prompt='%{$fg[white]%}$(kube_prompt) ${git_info}'

this delay updating of variable long enough effect of command run captured.

this how have configured in .zshrc:

kube_prompt() {    kubectl_current_context=$(kubectl config current-context)    kubectl_prompt="( \u2388 $kubectl_current_context )"    echo $kubectl_prompt }  rprompt='%f{81}$(kube_prompt)' 

and how looks like:

$ kubectl config use-context chip24                                                                                      ( ⎈ minikube )  switched context "chip24". $ kubectl config use-context hasura                                                                                        ( ⎈ chip24 )  switched context "hasura". $                                                                                                                          ( ⎈ hasura ) 

the unicode character ⎈ adds nice k8s logo effect it. :)


Comments