Skip to content

This is a Tmux plugin that allows you to display your current Kubernetes context in the Tmux status line

License

Notifications You must be signed in to change notification settings

masa0221/tmux-kube-status

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tmux Kube Status

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.

Preview

For a dynamic preview of how kube_status.tmux will look and behave, check out the GIF below:

kube_status.tmux in action

Installation

Recommended Method: Using tmux-plugin-manager (TPM)

Use tmux-plugin-manager (TPM) for easier installation and management.

  1. Add the following line to your .tmux.conf:
set -g @plugin 'masa0221/tmux-kube-status'
  1. Press prefix + I to fetch and install the plugin.

Manual Method

  1. Clone this repository:
git clone git@github.com:masa0221/tmux-kube-status.git
  1. In your .tmux.conf, source kube_status.tmux:
run-shell /path/to/tmux-kube-status/kube_status.tmux

Usage

To display your Kubernetes context in the Tmux status line, add this line to your .tmux.conf:

set-option -g status-right "#{kube_status}"

Note on Refresh Rate

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.

Configuration

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'

Configuration Table

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.*

Troubleshooting

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.

Debugging

Use --debug and --debug-with-color-code flags with tmux_kube_status.sh for debugging.

Contributing

Open an issue or submit a pull request if you'd like to contribute.

License

MIT

About

This is a Tmux plugin that allows you to display your current Kubernetes context in the Tmux status line

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages