kube_status.tmux
is a Tmux plugin that allows you to display your current Kubernetes context in the Tmux status line. The plugin enables you to change colors based on each context.
For a dynamic preview of how kube_status.tmux
will look and behave, check out the GIF below:
Use tmux-plugin-manager (TPM) for easier installation and management.
- Add the following line to your
.tmux.conf
:
set -g @plugin 'masa0221/tmux-kube-status'
- Press
prefix
+ I to fetch and install the plugin.
- Clone this repository:
git clone git@github.com:masa0221/tmux-kube-status.git
- In your
.tmux.conf
, sourcekube_status.tmux
:
run-shell /path/to/tmux-kube-status/kube_status.tmux
To display your Kubernetes context in the Tmux status line, add this line to your .tmux.conf
:
set-option -g status-right "#{kube_status}"
To minimize the chance of displaying outdated information, you may optionally set the status-interval
:
set-option -g status-interval 1
This will refresh the Tmux status line every second.
Here is an example of how to configure kube_status.tmux in your .tmux.conf
file. If not set, the plugin will use default values:
set -g @kube-status-format-prod '#[fg=colour255,bg=colour200,bold]'
set -g @kube-status-icon-prod '⚠️ '
set -g @kube-status-context-max-length '50'
Option | Description | Default |
---|---|---|
@kube-status-format-default |
Text color and background for default | #[fg=colour255,bg=colour27] |
@kube-status-format-dev |
Text color and background for dev environment | #[fg=colour255,bg=colour27] |
@kube-status-format-test |
Text color and background for test environment | #[fg=colour255,bg=colour28] |
@kube-status-format-stage |
Text color and background for staging environment | #[fg=colour255,bg=colour136] |
@kube-status-format-prod |
Text color and background for prod environment | #[fg=colour255,bg=colour200] |
@kube-status-icon-default |
Icon for default | ⎈ |
@kube-status-icon-dev |
Icon for dev environment | ⎈ |
@kube-status-icon-test |
Icon for test environment | ⎈ |
@kube-status-icon-stage |
Icon for staging environment | ⎈ |
@kube-status-icon-prod |
Icon for prod environment | ⎈ |
@kube-status-context-max-length |
Max length for Kubernetes context name | 20 |
@kube-status-namespace-max-length |
Max length for Kubernetes namespace | 20 |
@kube-status-empty-context-string |
String when no Kubernetes context is available | - |
@kube-status-dev-pattern |
Regex pattern for dev environment | .*dev.* |
@kube-status-test-pattern |
Regex pattern for test environment | .*test.* |
@kube-status-stg-pattern |
Regex pattern for staging environment | .*stg.*|.*stage.* |
@kube-status-prod-pattern |
Regex pattern for production environment | .*prod.* |
If your settings do not seem to take effect, you can verify the current values with tmux show-option
. For example, to check the value of @kube-status-format-dev
, you can use:
tmux show-option -gqv @kube-status-format-dev
This will show you the current setting, helping you to debug any configuration issues.
Use --debug
and --debug-with-color-code
flags with tmux_kube_status.sh
for debugging.
Open an issue or submit a pull request if you'd like to contribute.
MIT