A custom Powerline segment for displaying the current Kubernetes context and namespace
Project description
powerline-k8s
A custom Powerline segment for displaying the current Kubernetes context and namespace.
Installation
Using pip
$ pip install powerline-k8s
Local development
$ pip install --editable .
Installing the package in editable mode saves you from having to "re-install" to see the latest changes.
Configuration
Colorscheme
Add the following config items to your Powerline colorscheme config file (usually located at ~/.config/powerline/colorschemes/
),
see Powerline Colorschemes for more info.
{
"k8s": { "fg": "solarized:blue", "bg": "solarized:base02", "attrs": [] },
"k8s_namespace": { "fg": "solarized:red", "bg": "solarized:base02", "attrs": [] },
"k8s_context": { "fg": "solarized:blue", "bg": "solarized:base02", "attrs": [] },
"k8s:divider": { "fg": "gray4", "bg": "solarized:base02", "attrs": [] }
}
Segment
Add the following config item to your Powerline segments config file, see Powerline Segment reference for more info.
{
"function": "powerline_k8s.k8s",
"priority": 30
}
- If adding the segment to the shell, edit
~/.config/powerline/themes/shell/default.json
. - If adding the segment to the tmux status line, edit
~/.config/powerline/themes/tmux/default.json
.
Toggle visibility
Toggle entire segment or specific section's visibility with the following environment variables:
POWERLINE_K8S_SHOW
POWERLINE_K8S_SHOW_NS
Note: Full segment visibility takes precedence over namespace section visibility.
# toggle segment visibility
$ POWERLINE_K8S_SHOW=0 powerline-daemon --replace # hide powerline-k8s segment
$ POWERLINE_K8S_SHOW=1 powerline-daemon --replace # show powerline-k8s segment (default)
# toggle namespace section visibility
$ POWERLINE_K8S_SHOW_NS=0 powerline-daemon --replace # hide namespace section
$ POWERLINE_K8S_SHOW_NS=1 powerline-daemon --replace # show namespace section (default)
Alternatively you can add the following function to your shell for easier toggling:
toggle_powerline_k8s() {
case "$1" in
# pass the '-ns' flag to toggle namespace visibility
"-ns" | "--namespace")
if [[ "${POWERLINE_K8S_SHOW_NS:-1}" -eq 1 ]]; then
export POWERLINE_K8S_SHOW_NS=0
else
export POWERLINE_K8S_SHOW_NS=1
fi
;;
*)
# toggle segment visibility
if [[ "${POWERLINE_K8S_SHOW:-1}" -eq 1 ]]; then
export POWERLINE_K8S_SHOW=0
else
export POWERLINE_K8S_SHOW=1
fi
;;
esac
}
Docs
For more detailed documentation see https://j4ckofalltrades.github.io/powerline-k8s.
Demo
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for powerline_k8s-1.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e166078a16f3c5412ac6a9fb43645c9a6cedbf203b94e571b9361d1c6c1d445 |
|
MD5 | 8ad0069aab79bccd08b521da303dcdb2 |
|
BLAKE2b-256 | e35b33cd9229db0335a8ed8a3e6b1c988e8864c044ab3f0c7eafc5931d850d95 |