### Install Kubecolor with winget Source: https://kubecolor.github.io/setup/install For Windows users, install Kubecolor using the winget package manager. ```bash winget install --id Kubecolor.kubecolor ``` -------------------------------- ### Install Kubecolor with Scoop Source: https://kubecolor.github.io/setup/install For Windows users, install Kubecolor using the Scoop package manager. ```bash scoop install kubecolor ``` -------------------------------- ### Install Kubecolor with Zypper Source: https://kubecolor.github.io/setup/install For openSUSE users, this command adds the Kubecolor repository and installs the package. ```bash sudo zypper addrepo https://kubecolor.github.io/packages/rpm/kubecolor.repo sudo zypper install kubecolor ``` -------------------------------- ### Install Kubecolor with nix shell Source: https://kubecolor.github.io/setup/install Use this command to install Kubecolor using the 'nix shell' command. ```bash nix shell nixpkgs#kubecolor ``` -------------------------------- ### Setting Color Theme Source: https://kubecolor.github.io/reference/flags Example of specifying a color theme preset. ```bash kubecolor get pods --kubecolor-theme=dark ``` -------------------------------- ### Install Kubecolor with nix-shell Source: https://kubecolor.github.io/setup/install Use this command to install Kubecolor within a nix-shell environment. ```bash nix-shell -p kubecolor ``` -------------------------------- ### Using --kubecolor-stdin Source: https://kubecolor.github.io/reference/flags Examples of parsing and colorizing output from stdin or files. ```bash kubectl get pods > results.txt cat results.txt | kubecolor get pods --kubecolor-stdin ``` ```bash kubectl get pods > results.txt kubecolor get pods --kubecolor-stdin=results.txt ``` ```bash docker logs my-container | kubecolor logs --kubecolor-stdin ``` -------------------------------- ### Install Kubecolor with DNF5 Source: https://kubecolor.github.io/setup/install For Fedora 41+ users, this command adds the Kubecolor repository and installs the package. ```bash sudo dnf install dnf5-plugins sudo dnf config-manager addrepo --from-repofile https://kubecolor.github.io/packages/rpm/kubecolor.repo sudo dnf install kubecolor ``` -------------------------------- ### Install Kubectl Completions for PowerShell Source: https://kubecolor.github.io/setup/shells/powershell This script installs kubectl completions for PowerShell. It checks if kubectl is installed and then executes the completion script, making the $__kubectlCompleterBlock variable available for subsequent commands. ```powershell # Completion for kubectl # This needs to be added before Register-ArgumentCompleter if (Get-Command kubectl -ErrorAction SilentlyContinue) { # This also registers the $__kubectlCompleterBlock variable kubectl completion powershell | Out-String | Invoke-Expression } ``` -------------------------------- ### Install Kubecolor with aqua Source: https://kubecolor.github.io/setup/install For users of the aqua package manager, this command installs Kubecolor. ```bash aqua g -i kubecolor/kubecolor ``` -------------------------------- ### Parse Arguments and Prepare Kubectl Command Source: https://kubecolor.github.io/usage/how-it-works This example shows how kubecolor parses arguments, identifies subcommand flags, and transforms the command for kubectl execution. ```bash kubecolor --kubecolor-theme="light" get --pager="less -RF" pods -o wide --watch ``` ```bash kubectl get pods -o wide --watch ``` -------------------------------- ### Install Kubecolor with Flox Source: https://kubecolor.github.io/setup/install For users of Flox, a package manager built on Nix, install Kubecolor with this command. ```bash flox install kubecolor ``` -------------------------------- ### Compile kubecolor from source Source: https://kubecolor.github.io/setup/install Requires Go 1.22 or later to install the binary. ```bash go install github.com/kubecolor/kubecolor@latest ``` -------------------------------- ### Install Kubecolor with DNF4 Source: https://kubecolor.github.io/setup/install For Fedora 40 and earlier users, this command adds the Kubecolor repository and installs the package. ```bash sudo dnf install 'dnf-command(config-manager)' sudo dnf config-manager --add-repo https://kubecolor.github.io/packages/rpm/kubecolor.repo sudo dnf install kubecolor ``` -------------------------------- ### Install Kubecolor via DEB package Source: https://kubecolor.github.io/setup/install For Debian, Ubuntu, and derivatives, this script downloads and installs the latest .deb package, setting up the repository for future updates. ```bash sudo apt-get update sudo apt-get install apt-transport-https wget --yes wget -O /tmp/kubecolor.deb https://kubecolor.github.io/packages/deb/pool/main/k/kubecolor/kubecolor_$(wget -q -O- https://kubecolor.github.io/packages/deb/version)_$(dpkg --print-architecture).deb sudo dpkg -i /tmp/kubecolor.deb sudo apt update ``` -------------------------------- ### Install Kubecolor from AUR Source: https://kubecolor.github.io/setup/install For Arch Linux-based systems (Manjaro, EndeavourOS, etc.), install Kubecolor using the AUR helper 'yay'. ```bash yay -Syu kubecolor ``` -------------------------------- ### Install Kubecolor with Termux Source: https://kubecolor.github.io/setup/install For Android users, install Kubecolor using the Termux package manager. ```bash pkg install kubecolor ``` -------------------------------- ### Default kubecolor configuration file Source: https://kubecolor.github.io/reference/config This example shows the default values for the configuration file. Ensure the YAML tags used in documentation are omitted from the actual file. ```yaml # yaml-language-server: $schema=https://github.com/kubecolor/kubecolor/raw/main/config-schema.json kubectl: kubectl # path to kubectl executable preset: dark # color theme preset objFreshThreshold: 0 # ages below this uses theme.data.durationfresh coloring paging: never # whether to pipe supported subcommands to a pager ("auto" or "never") pager: # the command to use as pager; default uses $PAGER, less, or more ``` -------------------------------- ### Install Kubecolor with Homebrew Source: https://kubecolor.github.io/setup/install Use this command for MacOS and some Linux users with the Homebrew package manager. ```bash brew install kubecolor ``` -------------------------------- ### Install Kubecolor with Yum Source: https://kubecolor.github.io/setup/install For older RHEL-based systems using Yum, this command adds the Kubecolor repository and installs the package. ```bash type -p yum-config-manager >/dev/null || sudo yum install yum-utils sudo yum-config-manager --add-repo https://kubecolor.github.io/packages/rpm/kubecolor.repo sudo yum install kubecolor ``` -------------------------------- ### Install Kubecolor with asdf Source: https://kubecolor.github.io/setup/install For users of the asdf package manager, this command installs the latest version of Kubecolor from GitHub releases. ```bash asdf install kubecolor latest ``` -------------------------------- ### Install Kubecolor with mise Source: https://kubecolor.github.io/setup/install For users of the mise-en-place package manager, this command installs Kubecolor, which uses the aqua package behind the scenes. ```bash mise install kubecolor ``` -------------------------------- ### Install Kubecolor with MacPorts Source: https://kubecolor.github.io/setup/install For MacOS users, install Kubecolor using the MacPorts package manager. ```bash sudo port install kubecolor ``` -------------------------------- ### Remove and Reinstall Kubecolor with Homebrew Source: https://kubecolor.github.io/setup/install If you previously used the old Homebrew tap, use these commands to remove it and install the current version. ```bash brew uninstall kubecolor brew untap kubecolor/tap brew update brew install kubecolor ``` -------------------------------- ### Force Color Modes with --force-colors Flag Source: https://kubecolor.github.io/usage/how-it-works Examples of forcing specific color output modes (auto, basic, 256, truecolor, none) using the --force-colors flag. ```bash # Automatically detect color support, # but fallback to basic/4-bit colors if detection fails kubecolor get pods --force-colors=auto ``` ```bash # Force colors to basic/4-bit colors, # resulting in header color code `\x1b[37m` kubecolor get pods --force-colors=basic ``` ```bash # Force colors to 256/8-bit colors, # resulting in header color code `\x1b[38;5;66m` kubecolor get pods --force-colors=256 ``` ```bash # Force colors to truecolor/24-bit colors, # resulting in header color code `\x1b[38;2;90;132;135m` kubecolor get pods --force-colors=truecolor ``` ```bash # Forcing no colors, i.e. disabling colors kubecolor get pods --force-colors=none ``` -------------------------------- ### Set Kubectl Command with KUBECTL_COMMAND Source: https://kubecolor.github.io/reference/environment-variables Use this to change the kubectl command that Kubecolor runs. The default is `kubectl`. For example, you can set it to `kubectl1.19` or `oc` for OpenShift. It is recommended to use `KUBECOLOR_KUBECTL=kubectl` instead. ```bash export KUBECTL_COMMAND=kubectl # default ``` ```bash export KUBECTL_COMMAND=kubectl1.19 ``` ```bash export KUBECTL_COMMAND=oc # openshift ``` -------------------------------- ### Command-line Flag Usage Source: https://kubecolor.github.io/reference/flags Example of how kubecolor filters flags before invoking kubectl. ```bash kubecolor get pods --force-colors --namespace=kube-system ``` ```bash kubectl get pods --namespace=kube-system ``` -------------------------------- ### Handling Pager Errors Source: https://kubecolor.github.io/reference/flags Example of behavior when an invalid pager command is specified. ```bash kubecolor get pods --paging=auto --pager=does-not-exist # [kubecolor] [ERROR] failed to run pager: exec: "does-not-exist": executable file not found in $PATH # 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 ``` -------------------------------- ### Configure Logs Command Colors Source: https://kubecolor.github.io/reference/environment-variables Defines colors for keys, quoted strings, dates, source references, GUIDs, and severity levels (trace, debug, info, warn, error, fatal, panic) in 'kubectl logs' output. ```shell export KUBECOLOR_THEME_LOGS_KEY="$KUBECOLOR_THEME_DATA_KEY" ``` ```shell export KUBECOLOR_THEME_LOGS_QUOTEDSTRING="$KUBECOLOR_THEME_DATA_STRING" ``` ```shell export KUBECOLOR_THEME_LOGS_DATE="$KUBECOLOR_THEME_BASE_MUTED" ``` ```shell export KUBECOLOR_THEME_LOGS_SOURCEREF="$KUBECOLOR_THEME_BASE_MUTED" ``` ```shell export KUBECOLOR_THEME_LOGS_GUID="$KUBECOLOR_THEME_BASE_MUTED" ``` ```shell export KUBECOLOR_THEME_LOGS_SEVERITY_TRACE="$KUBECOLOR_THEME_BASE_MUTED" ``` ```shell export KUBECOLOR_THEME_LOGS_SEVERITY_DEBUG="$KUBECOLOR_THEME_BASE_MUTED" ``` ```shell export KUBECOLOR_THEME_LOGS_SEVERITY_INFO="$KUBECOLOR_THEME_BASE_SUCCESS" ``` ```shell export KUBECOLOR_THEME_LOGS_SEVERITY_WARN="$KUBECOLOR_THEME_BASE_WARNING" ``` ```shell export KUBECOLOR_THEME_LOGS_SEVERITY_ERROR="$KUBECOLOR_THEME_BASE_DANGER" ``` ```shell export KUBECOLOR_THEME_LOGS_SEVERITY_FATAL="$KUBECOLOR_THEME_BASE_DANGER" ``` ```shell export KUBECOLOR_THEME_LOGS_SEVERITY_PANIC="$KUBECOLOR_THEME_BASE_DANGER" ``` -------------------------------- ### Register Kubecolor Argument Completer in PowerShell Source: https://kubecolor.github.io/setup/shells/powershell This script registers the kubectl completion script for 'k', 'kubectl', and 'kubecolor' commands. It requires kubectl completions to be installed first. ```powershell # Reuse the kubectl completion on kubecolor and the aliases Register-ArgumentCompleter -CommandName 'k','kubectl','kubecolor' -ScriptBlock $__kubectlCompleterBlock ``` -------------------------------- ### Demonstrate Whitespace Variations in Color Codes Source: https://kubecolor.github.io/reference/types/color Whitespace is allowed within color codes and does not affect their semantic meaning. These examples show equivalent configurations with varying whitespace. ```bash # These are all semantically identical export KUBECOLOR_THEME_TABLE_HEADER="fg=white:bold:underline" export KUBECOLOR_THEME_TABLE_HEADER="fg=white : bold : underline" export KUBECOLOR_THEME_TABLE_HEADER="fg = white : bold : underline" export KUBECOLOR_THEME_TABLE_HEADER=" fg = white : bold : underline " ``` -------------------------------- ### Switching Themes via CLI, Environment Variables, and Config Source: https://kubecolor.github.io/customizing/themes Methods to apply a specific color theme temporarily or persistently. ```bash kubecolor get pods --kubecolor-theme=protanopia-dark ``` ```bash export KUBECOLOR_PRESET="protanopia-dark" ``` ```yaml preset: protanopia-dark ``` -------------------------------- ### Source kubectl completions Source: https://kubecolor.github.io/setup/shells/bash Add this to your ~/.bashrc to initialize kubectl completions before setting up custom completion logic. ```bash # This needs to be added before "complete -o default -F __start_kubectl ..." source <(kubectl completion bash) ``` -------------------------------- ### Configure Create Command Colors Source: https://kubecolor.github.io/reference/environment-variables Environment variables for styling output from the kubectl create command. ```bash export KUBECOLOR_THEME_CREATE_CREATED="$KUBECOLOR_THEME_BASE_SUCCESS" export KUBECOLOR_THEME_CREATE_DRYRUN="$KUBECOLOR_THEME_APPLY_DRYRUN" export KUBECOLOR_THEME_CREATE_FALLBACK="$KUBECOLOR_THEME_BASE_SUCCESS" ``` -------------------------------- ### Configure KUBECOLOR_PRESET Source: https://kubecolor.github.io/reference/environment-variables Select the color theme for kubecolor output. ```bash export KUBECOLOR_PRESET="dark" # default export KUBECOLOR_PRESET="light" export KUBECOLOR_PRESET="protanopia-dark" ``` -------------------------------- ### Configure Table Formatting Source: https://kubecolor.github.io/reference/environment-variables Environment variables for styling table headers and column cycling. ```bash export KUBECOLOR_THEME_TABLE_HEADER="$KUBECOLOR_THEME_BASE_INFO" export KUBECOLOR_THEME_TABLE_COLUMNS="$KUBECOLOR_THEME_BASE_INFO/$KUBECOLOR_THEME_BASE_SECONDARY" ``` -------------------------------- ### Configure Explain Command Colors Source: https://kubecolor.github.io/reference/environment-variables Defines colors for keys, required strings, and URLs within the 'kubectl explain' command output. The key color cycles based on indentation. ```shell export KUBECOLOR_THEME_EXPLAIN_KEY="$KUBECOLOR_THEME_BASE_KEY" ``` ```shell export KUBECOLOR_THEME_EXPLAIN_REQUIRED="$KUBECOLOR_THEME_BASE_DANGER" ``` -------------------------------- ### Configure Describe Command Colors Source: https://kubecolor.github.io/reference/environment-variables Environment variable for styling keys in describe output. ```bash export KUBECOLOR_THEME_DESCRIBE_KEY="$KUBECOLOR_THEME_BASE_KEY" ``` -------------------------------- ### Configure Ratio Colors Source: https://kubecolor.github.io/reference/environment-variables Environment variables for styling ratio outputs such as 0/0, n/n, and n/m. ```bash export KUBECOLOR_THEME_DATA_RATIO_ZERO="$KUBECOLOR_THEME_BASE_MUTED" export KUBECOLOR_THEME_DATA_RATIO_EQUAL="" export KUBECOLOR_THEME_DATA_RATIO_UNEQUAL="$KUBECOLOR_THEME_BASE_WARNING" ``` -------------------------------- ### Configure Help Command Colors Source: https://kubecolor.github.io/reference/environment-variables Defines colors for headers, flags, flag descriptions, URLs, and general text in the 'kubectl help' output. ```shell export KUBECOLOR_THEME_HELP_HEADER="$KUBECOLOR_THEME_TABLE_HEADER" ``` ```shell export KUBECOLOR_THEME_HELP_FLAG="$KUBECOLOR_THEME_BASE_SECONDARY" ``` ```shell export KUBECOLOR_THEME_HELP_FLAGDESC="$KUBECOLOR_THEME_BASE_INFO" ``` ```shell export KUBECOLOR_THEME_HELP_URL="$KUBECOLOR_THEME_BASE_SECONDARY" ``` ```shell export KUBECOLOR_THEME_HELP_TEXT="$KUBECOLOR_THEME_BASE_INFO" ``` -------------------------------- ### Run kubecolor via Docker Source: https://kubecolor.github.io/setup/install Execute kubecolor in a containerized environment, mounting the local kube config. ```bash docker run --rm -it -v $HOME/.kube:/home/nonroot/.kube:ro --env COLORTERM ghcr.io/kubecolor/kubecolor get pods ``` -------------------------------- ### Configure Apply Command Colors Source: https://kubecolor.github.io/reference/environment-variables Environment variables for styling output from the kubectl apply command. ```bash export KUBECOLOR_THEME_APPLY_CREATED="$KUBECOLOR_THEME_BASE_SUCCESS" export KUBECOLOR_THEME_APPLY_CONFIGURED="$KUBECOLOR_THEME_BASE_WARNING" export KUBECOLOR_THEME_APPLY_UNCHANGED="$KUBECOLOR_THEME_BASE_PRIMARY" export KUBECOLOR_THEME_APPLY_SERVERSIDE="$KUBECOLOR_THEME_BASE_WARNING" export KUBECOLOR_THEME_APPLY_DRYRUN="$KUBECOLOR_THEME_BASE_SECONDARY" export KUBECOLOR_THEME_APPLY_FALLBACK="$KUBECOLOR_THEME_BASE_SUCCESS" ``` -------------------------------- ### Configure Status Keyword Colors Source: https://kubecolor.github.io/reference/environment-variables Environment variables for styling resource status keywords. ```bash export KUBECOLOR_THEME_STATUS_SUCCESS="$KUBECOLOR_THEME_BASE_SUCCESS" export KUBECOLOR_THEME_STATUS_WARNING="$KUBECOLOR_THEME_BASE_WARNING" export KUBECOLOR_THEME_STATUS_ERROR="$KUBECOLOR_THEME_BASE_DANGER" ``` -------------------------------- ### Configure Expose Command Colors Source: https://kubecolor.github.io/reference/environment-variables Sets the color for exposed resources, such as 'deployment.apps/foo created'. ```shell export KUBECOLOR_THEME_EXPOSE_EXPOSED="$KUBECOLOR_THEME_BASE_PRIMARY" ``` -------------------------------- ### Enable Light Background with KUBECOLOR_LIGHT_BACKGROUND Source: https://kubecolor.github.io/reference/environment-variables This flag enables the light color preset, similar to the `--light-background` flag. It defaults to `false`. It is recommended to use `KUBECOLOR_PRESET=light` instead. ```bash export KUBECOLOR_LIGHT_BACKGROUND=true ``` -------------------------------- ### Configure Theme Variables Source: https://kubecolor.github.io/reference/environment-variables Override specific color settings for various UI elements and data types. ```bash # (color) general color for when things are bad export KUBECOLOR_THEME_BASE_DANGER="red" # (color) general color for when things are informational export KUBECOLOR_THEME_BASE_INFO="white" # (color) general color for when things are less relevant export KUBECOLOR_THEME_BASE_MUTED="gray:italic" # (color) general color for when things are focus export KUBECOLOR_THEME_BASE_PRIMARY="magenta" # (color) general color for when things are secondary focus export KUBECOLOR_THEME_BASE_SECONDARY="cyan" # (color) general color for when things are good export KUBECOLOR_THEME_BASE_SUCCESS="green" # (color) general color for when things are wrong export KUBECOLOR_THEME_BASE_WARNING="yellow" # (color-list) general color for keys export KUBECOLOR_THEME_BASE_KEY="$KUBECOLOR_THEME_BASE_SECONDARY" # (color) default when no specific mapping is found for the command export KUBECOLOR_THEME_DEFAULT="green" # (color) used on comments, e.g `# this is a comment` export KUBECOLOR_THEME_SHELL_COMMENT="$KUBECOLOR_THEME_BASE_MUTED" # (color) used on commands, e.g `kubectl` or `echo` export KUBECOLOR_THEME_SHELL_COMMAND="$KUBECOLOR_THEME_BASE_SUCCESS" # (color) used on arguments, e.g `get pods` in `kubectl get pods` export KUBECOLOR_THEME_SHELL_ARG="$KUBECOLOR_THEME_BASE_INFO" # (color) used on flags, e.g `--watch` in `kubectl get pods --watch` export KUBECOLOR_THEME_SHELL_FLAG="$KUBECOLOR_THEME_BASE_SECONDARY" # (color-list) used for the key export KUBECOLOR_THEME_DATA_KEY="$KUBECOLOR_THEME_BASE_KEY" # (color) used when value is a string export KUBECOLOR_THEME_DATA_STRING="$KUBECOLOR_THEME_BASE_INFO" # (color) used when value is true export KUBECOLOR_THEME_DATA_TRUE="$KUBECOLOR_THEME_BASE_SUCCESS" # (color) used when value is false export KUBECOLOR_THEME_DATA_FALSE="$KUBECOLOR_THEME_BASE_DANGER" # (color) used when the value is a number export KUBECOLOR_THEME_DATA_NUMBER="$KUBECOLOR_THEME_BASE_PRIMARY" ``` -------------------------------- ### Configure KUBECOLOR_KUBECTL Source: https://kubecolor.github.io/reference/environment-variables Specify the underlying kubectl command to execute. ```bash export KUBECOLOR_KUBECTL=kubectl # default export KUBECOLOR_KUBECTL=kubectl1.19 export KUBECOLOR_KUBECTL=oc # openshift ``` -------------------------------- ### Configure KUBECOLOR_OBJ_FRESH Source: https://kubecolor.github.io/reference/environment-variables Set a duration to change the color of objects based on their creation time. ```bash export KUBECOLOR_OBJ_FRESH="0" # default export KUBECOLOR_OBJ_FRESH="10h" ``` -------------------------------- ### Enable completions for kubecolor Source: https://kubecolor.github.io/setup/shells/bash Configure bash to use kubectl completion logic for the kubecolor command. ```bash complete -o default -F __start_kubectl kubecolor ``` -------------------------------- ### Configure Zsh completions Source: https://kubecolor.github.io/setup/shells/zsh Use these commands to enable shell completion for kubecolor by borrowing logic from kubectl. ```bash # Make "kubecolor" borrow the same completion logic as "kubectl" compdef kubecolor=kubectl ``` ```bash # This needs to be added before "compdef kubecolor=kubectl" source <(kubectl completion zsh) ``` ```bash kubectl completion zsh > "${fpath[1]}/_kubectl" ``` -------------------------------- ### Enable completions for kubecolor Source: https://kubecolor.github.io/setup/shells/fish Configure the kubecolor function to reuse existing kubectl completions. ```fish # reuse "kubectl" completions on "kubecolor" function kubecolor --wraps kubectl command kubecolor $argv end ``` -------------------------------- ### Configure Annotate Command Colors Source: https://kubecolor.github.io/reference/environment-variables Environment variables for styling output from the kubectl annotate command. ```bash export KUBECOLOR_THEME_ANNOTATE_ANNOTATED="$KUBECOLOR_THEME_BASE_SUCCESS" export KUBECOLOR_THEME_ANNOTATE_DRYRUN="$KUBECOLOR_THEME_APPLY_DRYRUN" export KUBECOLOR_THEME_ANNOTATE_FALLBACK="$KUBECOLOR_THEME_BASE_WARNING" ``` -------------------------------- ### Use Light Background Theme Source: https://kubecolor.github.io/usage/getting-started To use colors better suited for terminals with a light background, supply the `--light-background` flag. ```bash kubecolor --light-background get pods ``` -------------------------------- ### Troubleshoot Docker permission errors Source: https://kubecolor.github.io/setup/install Identify and resolve permission denied errors when accessing the kube config file. ```text error: error loading config file "/home/nonroot/.kube/config": open /home/nonroot/.kube/config: permission denied ``` ```bash chmod 644 ~/.kube/config ``` -------------------------------- ### Defining Custom Color Themes Source: https://kubecolor.github.io/customizing/themes Customizing specific output colors using environment variables or a YAML configuration file. ```bash export KUBECOLOR_THEME_DATA_NULL="gray:italic" export KUBECOLOR_THEME_TABLE_HEADER="fg=white:bold:underline" export KUBECOLOR_THEME_STDERR_ERROR="fg=yellow:bg=red:bold" ``` ```yaml theme: data: "null": gray:italic table: header: fg=white:bold:underline stderr: error: fg=yellow:bg=red:bold ``` -------------------------------- ### Create kubectl and k aliases in Fish Source: https://kubecolor.github.io/setup/shells/fish Define aliases for kubectl and k that wrap the kubecolor command with completion support. ```fish # adds alias for "kubectl" to "kubecolor" with completions function kubectl --wraps kubectl command kubecolor $argv end # adds alias for "k" to "kubecolor" with completions function k --wraps kubectl command kubecolor $argv end ``` -------------------------------- ### --pager=cmd Source: https://kubecolor.github.io/reference/flags Configures the specific command used for paging Kubecolor's output. ```APIDOC ## `--pager=cmd` ### Description Configures which pager command to pipe kubecolor’s output through (if paging is enabled). Defaults to: * `less -RF` if `less` executable is found in `$PATH`, * `more` if `more` executable is found in `$PATH`, * if neither, then defaults to empty string. If no default pager is found, or if pager is reset via `--pager=""`, then paging is effectively disabled. If pager was found but failed to execute, or if pager was set to something invalid like `--pager=does-not-exist`, then kubecolor will log an error message but continue with the execution as normal. ### Method N/A (Command-line flag) ### Endpoint N/A (Command-line flag) ### Parameters #### Query Parameters - **`--pager`** (string) - Optional - The command to use as a pager. If set to an empty string (`--pager=""`), paging is disabled. If an invalid command is provided, an error is logged, but execution continues. ### Request Example ``` kubecolor get pods --paging=auto --pager=less ``` ### Error Handling Example ``` kubecolor get pods --paging=auto --pager=does-not-exist # [kubecolor] [ERROR] failed to run pager: exec: "does-not-exist": executable file not found in $PATH # 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 ``` ``` -------------------------------- ### Configure Version Command Colors Source: https://kubecolor.github.io/reference/environment-variables Sets the color for the key in the 'kubectl version' output. ```shell export KUBECOLOR_THEME_VERSION_KEY="$KUBECOLOR_THEME_BASE_KEY" ``` -------------------------------- ### Source kubectl completions Source: https://kubecolor.github.io/setup/shells/fish Add this command to your fish config file before the function definitions to ensure kubectl completions are available. ```fish # This needs to be added before "function ... --wraps kubectl" kubectl completion fish | source ``` -------------------------------- ### Enable completions for alias k Source: https://kubecolor.github.io/setup/shells/bash Configure bash to use kubectl completion logic for the k alias. ```bash alias k=kubectl complete -o default -F __start_kubectl k ``` -------------------------------- ### Configure Data Type Colors Source: https://kubecolor.github.io/reference/environment-variables Environment variables for styling data types like nulls, quantities, and durations. ```bash export KUBECOLOR_THEME_DATA_NULL="$KUBECOLOR_THEME_BASE_MUTED" export KUBECOLOR_THEME_DATA_QUANTITY="$KUBECOLOR_THEME_DATA_NUMBER" export KUBECOLOR_THEME_DATA_DURATION="" export KUBECOLOR_THEME_DATA_DURATIONFRESH="$KUBECOLOR_THEME_BASE_SUCCESS" ``` -------------------------------- ### Configure KUBECOLOR_CONFIG Source: https://kubecolor.github.io/reference/environment-variables Override the default path for the kubecolor configuration file. ```bash export KUBECOLOR_CONFIG="$HOME/.kube/color.yaml" # default export KUBECOLOR_CONFIG="$HOME/.config/kubecolor.yaml" ``` -------------------------------- ### Set Kubecolor Theme Environment Variables Source: https://kubecolor.github.io/reference/types/color Configure Kubecolor themes by exporting environment variables. These variables define the color and style for different output elements. ```bash export KUBECOLOR_THEME_DATA_NULL="gray:italic" export KUBECOLOR_THEME_TABLE_HEADER="fg=white:bold:underline" export KUBECOLOR_THEME_STDERR_ERROR="fg=yellow:bg=red:bold" export KUBECOLOR_THEME_STDERR_ERROR="#c0ffee" ``` -------------------------------- ### Configure Rollout Command Colors Source: https://kubecolor.github.io/reference/environment-variables Sets colors for various rollout events like rolled back, paused, resumed, and restarted resources. ```shell export KUBECOLOR_THEME_ROLLOUT_ROLLEDBACK="$KUBECOLOR_THEME_BASE_WARNING" ``` ```shell export KUBECOLOR_THEME_ROLLOUT_PAUSED="$KUBECOLOR_THEME_BASE_PRIMARY" ``` ```shell export KUBECOLOR_THEME_ROLLOUT_RESUMED="$KUBECOLOR_THEME_BASE_SECONDARY" ``` ```shell export KUBECOLOR_THEME_ROLLOUT_RESTARTED="$KUBECOLOR_THEME_BASE_WARNING" ``` -------------------------------- ### --light-background Source: https://kubecolor.github.io/reference/flags Enables a color preset suitable for light terminal backgrounds, improving readability. ```APIDOC ## `--light-background` ### Description When your terminal’s background color is something light (e.g white), default color preset might look too bright and not readable. If so, specify `--light-background` as a command line argument. kubecolor will use a color preset for light-background environment. This is an alias for `--kubecolor-theme=light`. ### Method N/A (Command-line flag) ### Endpoint N/A (Command-line flag) ### Parameters This flag does not accept any parameters. ``` -------------------------------- ### --kubecolor-theme Source: https://kubecolor.github.io/reference/flags Sets a specific color theme preset for Kubecolor's output. ```APIDOC ## `--kubecolor-theme` ### Description Sets the kubecolor color theme preset. You must provide a value for this flag. ### Method N/A (Command-line flag) ### Endpoint N/A (Command-line flag) ### Parameters #### Query Parameters - **`--kubecolor-theme`** (string) - Required - The name of the color theme preset to use (e.g., `dark`, `light`). ### Request Example ``` kubecolor get pods --kubecolor-theme=dark ``` ### See Also - Customizing / Color themes ``` -------------------------------- ### Configure Scale Command Colors Source: https://kubecolor.github.io/reference/environment-variables Defines the color for scaled resources, such as 'deployment.apps/foo scaled'. ```shell export KUBECOLOR_THEME_SCALE_SCALED="$KUBECOLOR_THEME_BASE_WARNING" ``` -------------------------------- ### Configure Delete Command Colors Source: https://kubecolor.github.io/reference/environment-variables Environment variables for styling output from the kubectl delete command. ```bash export KUBECOLOR_THEME_DELETE_DELETED="$KUBECOLOR_THEME_BASE_DANGER" export KUBECOLOR_THEME_DELETE_DRYRUN="$KUBECOLOR_THEME_APPLY_DRYRUN" export KUBECOLOR_THEME_DELETE_FALLBACK="$KUBECOLOR_THEME_BASE_DANGER" ``` -------------------------------- ### Flag Syntax Requirements Source: https://kubecolor.github.io/reference/flags Demonstrates the required --flag=value syntax versus the unsupported space-separated syntax. ```bash # good: kubecolor --kubecolor-stdin=foo kubecolor --pager=foo # bad: kubecolor --kubecolor-stdin foo kubecolor --pager foo ``` -------------------------------- ### --kubecolor-version Source: https://kubecolor.github.io/reference/flags Prints the version of Kubecolor itself, not the version of kubectl. ```APIDOC ## `--kubecolor-version` ### Description Prints the version of kubecolor (not kubectl one). ### Method N/A (Command-line flag) ### Endpoint N/A (Command-line flag) ### Parameters This flag does not accept any parameters. ``` -------------------------------- ### Dynamic TTY Support for Colorization Source: https://kubecolor.github.io/usage/how-it-works Demonstrates how kubecolor automatically disables colorization when output is redirected to a file or piped, and how to force color output. ```bash # Prints with color codes kubecolor get pods ``` ```bash # Automatically disables color codes for these two: kubecolor get pods > result.txt kubecolor get pods | grep Running ``` ```bash # Force kubecolor to print color codes anyways kubecolor get pods --force-colors > result.txt ``` -------------------------------- ### Configure Fresh Object Threshold Source: https://kubecolor.github.io/customizing/obj-fresh Set the duration threshold for fresh object highlighting using either an environment variable or the configuration file. ```bash export KUBECOLOR_OBJ_FRESH="10h" ``` ```yaml objFreshThreshold: 10h ``` -------------------------------- ### Configure PAGER Source: https://kubecolor.github.io/reference/environment-variables Set the default system pager used if KUBECOLOR_PAGER is unset. ```bash export PAGER="less" ``` -------------------------------- ### Configuring Fallback Colors Source: https://kubecolor.github.io/customizing/themes Using base color variables to update multiple related output elements simultaneously. ```bash export KUBECOLOR_THEME_BASE_SUCCESS="light-blue:italic" ``` ```yaml theme: base: success: light-blue:italic ``` ```bash export KUBECOLOR_THEME_STATUS_SUCCESS="light-blue:italic" export KUBECOLOR_THEME_APPLY_CREATED="light-blue:italic" # omitting other uses of the "base.success" fallback color for brevity ``` ```yaml theme: apply: created: light-blue:italic status: success: light-blue:italic # omitting other uses of the "base.success" fallback color for brevity ``` -------------------------------- ### Configure KUBECOLOR_PAGER Source: https://kubecolor.github.io/reference/environment-variables Define the pager application to use for output. ```bash export KUBECOLOR_PAGER="less" ``` -------------------------------- ### Alias oc to Kubecolor Source: https://kubecolor.github.io/customizing/custom-kubectl Create a shell alias to make the 'oc' command execute 'kubecolor'. This allows using Kubecolor's features with the OpenShift CLI. ```bash alias oc="kubecolor" ``` -------------------------------- ### Configure KUBECOLOR_PAGING Source: https://kubecolor.github.io/reference/environment-variables Control whether output is piped to a pager. ```bash export KUBECOLOR_PAGING="auto" export KUBECOLOR_PAGING="never" # default ``` -------------------------------- ### Configure Drain Command Colors Source: https://kubecolor.github.io/reference/environment-variables Environment variables for styling output from the kubectl drain command. ```bash export KUBECOLOR_THEME_DRAIN_CORDONED="$KUBECOLOR_THEME_BASE_PRIMARY" export KUBECOLOR_THEME_DRAIN_EVICTINGPOD="$KUBECOLOR_THEME_BASE_MUTED" export KUBECOLOR_THEME_DRAIN_EVICTED="$KUBECOLOR_THEME_BASE_WARNING" export KUBECOLOR_THEME_DRAIN_DRAINED="$KUBECOLOR_THEME_BASE_SUCCESS" ``` -------------------------------- ### --kubecolor-stdin Source: https://kubecolor.github.io/reference/flags Allows Kubecolor to parse and print output without executing kubectl, useful for dry runs or colorizing arbitrary output. It can read from stdin or a specified file. ```APIDOC ## `--kubecolor-stdin` ### Description Don’t run `kubectl` but instead only parse and print. Works as a sort of “dry run” for kubecolor coloring. The arguments for the kubecolor command (such as `get pods` or `describe pod`) still matters as they tell kubecolor how to parse and colorize the output. By default if you only supply the `--kubecolor-stdin` flag with no value then it will read from stdin. ### Method N/A (Command-line flag) ### Endpoint N/A (Command-line flag) ### Parameters #### Query Parameters - **`--kubecolor-stdin`** (string) - Optional - If no value is provided, reads from stdin. If a value is provided, it is treated as a file path to read from. ### Request Example **Reading from stdin:** ``` kubectl get pods > results.txt cat results.txt | kubecolor get pods --kubecolor-stdin ``` **Reading from a file:** ``` kubectl get pods > results.txt kubecolor get pods --kubecolor-stdin=results.txt ``` **Colorizing arbitrary output (e.g., Docker logs):** ``` docker logs my-container | kubecolor logs --kubecolor-stdin ``` ``` -------------------------------- ### Configure Options Command Colors Source: https://kubecolor.github.io/reference/environment-variables Sets the color for flags, such as '--kubeconfig', in the 'kubectl options' output. ```shell export KUBECOLOR_THEME_OPTIONS_FLAG="$KUBECOLOR_THEME_BASE_SECONDARY" ``` -------------------------------- ### Configure Patch Command Colors Source: https://kubecolor.github.io/reference/environment-variables Defines colors for patched resources, such as 'deployment.apps/foo patched', and dry run messages. ```shell export KUBECOLOR_THEME_PATCH_PATCHED="$KUBECOLOR_THEME_BASE_WARNING" ``` -------------------------------- ### Alias oc to Kubecolor with Environment Variable Source: https://kubecolor.github.io/customizing/custom-kubectl Create a shell alias for 'oc' that first sets the KUBECOLOR_KUBECTL environment variable to 'oc' and then executes 'kubecolor'. This ensures Kubecolor uses the OpenShift CLI. ```bash alias oc="env KUBECOLOR_KUBECTL=oc kubecolor" ``` -------------------------------- ### Configure Diff Command Colors Source: https://kubecolor.github.io/reference/environment-variables Environment variables for styling added, removed, and unchanged lines in diff output. ```bash export KUBECOLOR_THEME_DIFF_ADDED="$KUBECOLOR_THEME_BASE_SUCCESS" export KUBECOLOR_THEME_DIFF_REMOVED="$KUBECOLOR_THEME_BASE_DANGER" export KUBECOLOR_THEME_DIFF_UNCHANGED="$KUBECOLOR_THEME_BASE_MUTED" ``` -------------------------------- ### Configure alternating table column colors Source: https://kubecolor.github.io/reference/types/color-list Sets a sequence of colors for table columns using a slash-separated list. ```bash export KUBECOLOR_THEME_TABLE_COLUMNS="red/green/blue" ``` ```bash export KUBECOLOR_THEME_TABLE_COLUMNS="bg=red:underline/bg=green:italic/bg=blue:bold" ``` -------------------------------- ### Configure Label Command Colors Source: https://kubecolor.github.io/reference/environment-variables Sets colors for actions related to adding, removing, or not changing labels on Kubernetes resources. ```shell export KUBECOLOR_THEME_LABEL_LABELED="$KUBECOLOR_THEME_BASE_SUCCESS" ``` ```shell export KUBECOLOR_THEME_LABEL_UNLABELED="$KUBECOLOR_THEME_BASE_WARNING" ``` ```shell export KUBECOLOR_THEME_LABEL_NOTLABELED="$KUBECOLOR_THEME_BASE_MUTED" ``` -------------------------------- ### Replace kubectl with Kubecolor Source: https://kubecolor.github.io/usage/getting-started To use Kubecolor, simply replace the `kubectl` command with `kubecolor` for any kubectl command. ```bash # instead of this: kubectl get pods # use this: kubecolor get pods ``` -------------------------------- ### Configure KUBECOLOR_FORCE_COLORS Source: https://kubecolor.github.io/reference/environment-variables Force color output, useful when using kubecolor with the watch command. ```bash # Add this line to your ~/.bashrc, ~/.zshrc, or similar: alias watch='KUBECOLOR_FORCE_COLORS=auto watch --color ' # Usage: watch kubecolor get pods ``` -------------------------------- ### Override Configuration Path Source: https://kubecolor.github.io/reference/config Use the KUBECOLOR_CONFIG environment variable to specify a custom configuration file path. ```bash KUBECOLOR_CONFIG ``` -------------------------------- ### Force Color Output with Kubecolor Source: https://kubecolor.github.io/usage/getting-started Use the `--force-colors` flag to enable colorization even when Kubecolor detects that the output is not a terminal or does not support colors. This is useful when piping output to tools like `cat -A`. ```bash 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 ``` ```bash 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$ ``` -------------------------------- ### --force-colors Source: https://kubecolor.github.io/reference/flags Forces Kubecolor to output colorized results even when the output is not a TTY, useful for piping to other commands. ```APIDOC ## `--force-colors` ### Description By default, kubecolor never output the result in colors when the tty is not a terminal standard output. If you want to force kubecolor to show the result in colors for non-terminal tty, you can specify this flag. For example, when you want to pass kubecolor result to grep (e.g `kubecolor get pods --force-colors | grep pod_name`), this option is useful. It supports multiple values in the form of `--force-colors=...`. Just specifying `--force-colors` is the same as `--force-colors=auto`. ### Method N/A (Command-line flag) ### Endpoint N/A (Command-line flag) ### Parameters #### Query Parameters - **`--force-colors`** (string) - Optional - Can be set to `auto` (default) or other values to force color output. If specified without a value, it defaults to `auto`. ### See Also - Usage / How it works # Dynamic color support ``` -------------------------------- ### Set Default Kubecolor Configuration Path Source: https://kubecolor.github.io/reference/config Sets the KUBECOLOR_CONFIG environment variable to the default location for the Kubecolor configuration file. ```bash export KUBECOLOR_CONFIG="$HOME/.kube/color.yaml" ``` -------------------------------- ### Configure Stderr Output Colors Source: https://kubecolor.github.io/reference/environment-variables Environment variables for styling error messages and resource-not-found outputs. ```bash export KUBECOLOR_THEME_STDERR_ERROR="$KUBECOLOR_THEME_BASE_DANGER" export KUBECOLOR_THEME_STDERR_NONEFOUND="$KUBECOLOR_THEME_DATA_NULL" export KUBECOLOR_THEME_STDERR_NONEFOUNDNAMESPACE="$KUBECOLOR_THEME_DATA_STRING" export KUBECOLOR_THEME_STDERR_DEFAULT="" ``` -------------------------------- ### Pipe Kubectl Output Through Pager and Kubecolor Logic Source: https://kubecolor.github.io/usage/how-it-works Illustrates how kubecolor pipes kubectl output through its parsing logic and then to a specified pager when paging is enabled. ```bash kubectl get pods -o wide --watch | kubecolor-parsing-logic | less -RF ``` -------------------------------- ### Configure Uncordon Command Colors Source: https://kubecolor.github.io/reference/environment-variables Sets the color for uncordoned nodes, such as 'node/my-worker-node-01 uncordoned'. ```shell export KUBECOLOR_THEME_UNCORDON_UNCORDONED="$KUBECOLOR_THEME_BASE_SECONDARY" ``` -------------------------------- ### Set OpenShift CLI (oc) via Config File Source: https://kubecolor.github.io/customizing/custom-kubectl Configure Kubecolor to use the OpenShift CLI ('oc') by setting the 'kubectl' field in its configuration file to 'oc'. ```yaml kubectl: oc ``` -------------------------------- ### Set Kubecolor Aliases in PowerShell Profile Source: https://kubecolor.github.io/setup/shells/powershell Add these lines to your PowerShell profile to alias 'kubectl' and 'k' to 'kubecolor'. Ensure your profile file exists and is accessible. ```powershell Set-Alias -Name kubectl -Value kubecolor Set-Alias -Name k -Value kubectl ``` -------------------------------- ### Set OpenShift CLI (oc) via Environment Variable Source: https://kubecolor.github.io/customizing/custom-kubectl Configure Kubecolor to use the OpenShift CLI ('oc') by setting the KUBECOLOR_KUBECTL environment variable to 'oc'. ```bash export KUBECOLOR_KUBECTL="oc" ``` -------------------------------- ### Alias kubectl to Kubecolor Source: https://kubecolor.github.io/usage/getting-started To make colorized kubectl the default, you can set up an alias in your shell configuration. ```bash alias kubectl="kubecolor" ```