A custom Powerline segment for displaying the current Kubernetes context and namespace
Project description
A custom Powerline segment for displaying the current Kubernetes context and namespace.
Installation
Using pip
$ pip install powerline-k8s
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
.
Alternative config location
If your Kubernetes config file is not in the default location ~/.kube/config
, you can point to it by setting
the value of the $KUBECONFIG
environment variable to where your config file is.
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
}
Demo
Stats
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
File details
Details for the file powerline_k8s-1.5.3.tar.gz
.
File metadata
- Download URL: powerline_k8s-1.5.3.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9a40424807422e6e45e0df1c971ec6306aa283055a8dc676f88f976e0c6f2b3 |
|
MD5 | 013595fa5c2008f66bdbe1e9f1864d6c |
|
BLAKE2b-256 | 80572b2f3626f625a3b74f15916d90e73fedcccfb3ef92baa15adf2f917fbdd7 |
File details
Details for the file powerline_k8s-1.5.3-py3-none-any.whl
.
File metadata
- Download URL: powerline_k8s-1.5.3-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f28f900468012fcf8483079f1559d2ee62c761394f839197b0a7c4eb602586af |
|
MD5 | d8b4659a512116c939adf09eb9814536 |
|
BLAKE2b-256 | dd00d47ff3202fd9848517503eb1427f04a68d94ec7885a9699019b12d4dc9f4 |