Skip to content

Usage

First, make sure to install kubecolor: Setup / Installation.

Kubecolor understands every subcommands and options which are available for kubectl. What you have to do is just use kubecolor instead of kubectl like:

Terminal window
# instead of this:
kubectl get pods
# use this:
kubecolor get pods

If you want to make the colorized kubectl default on your shell, then override kubectl to become an alias instead:

~/.bashrc
alias kubectl="kubecolor"

Sample:

kubectl get podsNAME READY STATUS RESTARTS AGE nginx-7c5ddbdf54-9d575 0/1 ContainerCreating 0 15m nginx-7c5ddbdf54-f6wft 1/1 Running 0 15m nginx-7c5ddbdf54-h6dnn 1/1 Terminating 0 15m nginx-7c5ddbdf54-vtsqw 0/1 CrashLoopBackOff 0 15m

Read more on shell configuration:

Forcing colors

Kubecolor will automatically disable its colorization if it detects that its output (stdout) is not a terminal or is a terminal that does not support colors. To override this behavior, you can for example use the --force-colors flag:

Terminal window
kubecolor get pods | cat -A
#NAME READY STATUS RESTARTS AGE
#nginx-dnmv5 1/1 Running 0 6d6h
#nginx-m8pbc 1/1 Running 0 6d6h
#nginx-qdf9b 1/1 Running 0 6d6h
kubecolor get pods --force-colors | cat -A
#^[[1mNAME READY STATUS RESTARTS AGE^[[0m$
#^[[37mnginx-dnmv5^[[0m ^[[36m1/1^[[0m ^[[32mRunning^[[0m ^[[36m0^[[0m ^[[37m6d6h^[[0m$
#^[[37mnginx-m8pbc^[[0m ^[[36m1/1^[[0m ^[[32mRunning^[[0m ^[[36m0^[[0m ^[[37m6d6h^[[0m$
#^[[37mnginx-qdf9b^[[0m ^[[36m1/1^[[0m ^[[32mRunning^[[0m ^[[36m0^[[0m ^[[37m6d6h^[[0m$

The inverse can also be done by telling kubecolor to not use colors via the --plain flag.

Read more about configuration options at our reference docs:

Themes

Theming was introduced in v0.3.0, and has a lot of configs available to provide fine-grained control over the colorization of the output.

In short, you can for example supply the --light-background flag to instead use colors that are better suited for terminals with light background:

kubectl get pods --light-backgroundNAME READY STATUS RESTARTS AGE nginx-7c5ddbdf54-9d575 0/1 ContainerCreating 0 15m nginx-7c5ddbdf54-f6wft 1/1 Running 0 15m nginx-7c5ddbdf54-h6dnn 1/1 Terminating 0 15m nginx-7c5ddbdf54-vtsqw 0/1 CrashLoopBackOff 0 15m

Alternatively, we also have some colorblind-friendly themes available:

kubectl get pods --kubecolor-theme=protanopia-darkNAME READY STATUS RESTARTS AGE nginx-7c5ddbdf54-9d575 0/1 ContainerCreating 0 15m nginx-7c5ddbdf54-f6wft 1/1 Running 0 15m nginx-7c5ddbdf54-h6dnn 1/1 Terminating 0 15m nginx-7c5ddbdf54-vtsqw 0/1 CrashLoopBackOff 0 15m

Read more: