kubectx and kubens highlight the current context or namespace in their list output. You can customize these colors or disable color output entirely.
Current Implementation (Go-based)
The Go implementation (v0.9.0+) uses a simplified color scheme with limited customization options.Default Colors
The current context/namespace is displayed in green and bold when listing:Disabling Colors
To disable all color output, set theNO_COLOR environment variable:
Legacy Implementation (Bash-based)
The original Bash implementation offers more color customization through environment variables.Customizing Foreground and Background Colors
For the Bash implementation, you can customize both the text (foreground) and background colors using thetput command:
Color Code Reference
Thetput command uses the following color codes:
| Code | Color |
|---|---|
| 0 | Black |
| 1 | Red |
| 2 | Green |
| 3 | Yellow |
| 4 | Blue |
| 5 | Magenta |
| 6 | Cyan |
| 7 | White |
Examples
Blue text on white background
Red text on black background
Cyan text with default background
Default Colors (Bash)
If you don’t set these variables, the Bash implementation uses:- Foreground: Yellow (color code 3)
- Background: Dark/Black (color code 0)
Making Changes Permanent
To make your color preferences permanent, add the export commands to your shell configuration file:Bash
Add to~/.bashrc or ~/.bash_profile:
Zsh
Add to~/.zshrc:
Fish
Add to~/.config/fish/config.fish:
Remember to restart your shell or source the configuration file for changes to take effect:
Checking Your Implementation
To determine which implementation you’re using:- If the output shows a version number (e.g.,
0.9.x), you’re using the Go implementation - If the output is minimal or shows bash script info, you’re using the Bash implementation