typewritten icon indicating copy to clipboard operation
typewritten copied to clipboard

Can we add kubernetes integration?

Open mosheavni opened this issue 5 years ago • 3 comments

Is your feature request related to a problem? Please describe. No, just a feature to display the kubernetes cluster I'm in + the namespace

Describe the solution you'd like To display the kubernetes cluster I'm in + the namespace

Describe alternatives you've considered If it would be possible to add my custom functions that could also work.

mosheavni avatar Dec 03 '20 14:12 mosheavni

Hey @Moshem123 !

What would your function look like?

I really like the option of letting a user add a prefix to the left prompt that could be a function or simply text, so we might go with that.

reobin avatar Dec 04 '20 16:12 reobin

Here's what I want to add: https://github.com/jonmosco/kube-ps1

mosheavni avatar Dec 06 '20 10:12 mosheavni

@mosheavni Here is my solution to the problem:

image

k8s_current_context() {
  echo "[k8s:$(kubectl config current-context | awk -F'/' '{print $2}')]";
}

export TYPEWRITTEN_RIGHT_PROMPT_PREFIX_FUNCTION=k8s_current_context
export TYPEWRITTEN_COLORS="right_prompt_prefix:#FF80BF"

Specifically you may need to tailor any post processing of the current context, which in my case I achieve with: awk -F'/' '{print $2}'

itay-grudev avatar Mar 27 '23 16:03 itay-grudev