ahmetb / kubectx

Faster way to switch between clusters and namespaces in kubectl
https://kubectx.dev
Apache License 2.0
17.71k stars 1.26k forks source link

TERM=vt100 causing empty output #57

Closed cdenneen closed 6 years ago

cdenneen commented 6 years ago

Currently if using something like no color or vt100 terminal you won't see what the current context is... if the terminal supports color it will be bold and a color.

  1. For non-color terminals add * to current context?

~ » export TERM=vt100 ~ » kubectx aws docker-for-desktop k8s

~ » export TERM=xterm ~ » kubectx aws docker-for-desktop k8s

  1. Add option to only print current context (theoretically this and similar option for kubens can be used to add to PS1 prompt)

kubectx -- k8s

cdenneen commented 6 years ago

53 was supposed to add NO_COLOR but upgrading from 0.4.0 -> 0.5.0 with homebrew just resulted in EMPTY responses when TERM=vt100

~ » export TERM=vt100
~ » kubectx
~ » kubens
~ » export TERM=xterm
~ » kubectx
aws
docker-for-desktop
k8s
~ » kubens
default
jenkins
kube-public
kube-system
ahmetb commented 6 years ago

For non-color terminals add * to current context?

we discussed this previously and it's not a great idea. we want commands like kubectx -d $(kubectx) to work. if you want to see the current-context in your PS1 string, try out kube-ps1.

Add option to only print current context

again we discussed this many times in #14, #28, #51. you can either use https://github.com/jonmosco/kube-ps1 or kubectl config current-context. No need a kubectx feature for this.

ahmetb commented 6 years ago

Sorry, I'll reopen this to keep track of NO_COLOR empty output issue.

ahmetb commented 6 years ago

(This is regarding your report about empty output when TERM=vt100.)

It looks like the tput command we're calling to set the colors is failing when TERM=vt100. I asked about it here:

https://unix.stackexchange.com/questions/464028/why-is-tput-failing-silently-on-term-vt100 would be interesting to learn why.

In the meanwhile, instead of doing

yellow=$(tput setaf 3)

we can do:

yellow=$(tput setaf 3 || true)

to ignore errors, but I don't think this is a good idea, since VT-100 has color support.

ahmetb commented 6 years ago

I just fixed this by ignoring tput failure. vt100 does not have colors, so this will just print black and white output.

I'm not convinced people still use vt100 :)