diff --git a/.gitignore b/.gitignore index ec4610be..f27e5f8e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,61 @@ tags config.json powerline-shell.json .DS_Store + +# editors *sublime* +.vscode/ +.idea/ + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + diff --git a/powerline_shell/colortrans.py b/powerline_shell/colortrans.py index 1c385522..c1e991b0 100755 --- a/powerline_shell/colortrans.py +++ b/powerline_shell/colortrans.py @@ -100,19 +100,19 @@ def rgbstring2tuple(s): (95, 135, 215): 68, (95, 135, 255): 69, (95, 175, 0): 70, - (95, 175, 95) : 71, + (95, 175, 95): 71, (95, 175, 135): 72, (95, 175, 175): 73, (95, 175, 215): 74, (95, 175, 255): 75, (95, 215, 0): 76, - (95, 215, 95) : 77, + (95, 215, 95): 77, (95, 215, 135): 78, (95, 215, 175): 79, (95, 215, 215): 80, (95, 215, 255): 81, (95, 255, 0): 82, - (95, 255, 95) : 83, + (95, 255, 95): 83, (95, 255, 135): 84, (95, 255, 175): 85, (95, 255, 215): 86, diff --git a/powerline_shell/segments/kube_context.py b/powerline_shell/segments/kube_context.py new file mode 100644 index 00000000..8285b89a --- /dev/null +++ b/powerline_shell/segments/kube_context.py @@ -0,0 +1,16 @@ +""" +Shows the exported kubectl context +e.g $ export KUBECONFIG=~/.kube/config-staging-cluster +""" +from ..utils import BasicSegment +import os + + +class Segment(BasicSegment): + def add_to_powerline(self): + kube_context = os.environ.get("KUBECONFIG") + if kube_context: + self.powerline.append(" kctx:%s " % os.path.basename(kube_context), + self.powerline.theme.KUBE_CONTEXT_FG, + self.powerline.theme.KUBE_CONTEXT_BG) + diff --git a/powerline_shell/themes/basic.py b/powerline_shell/themes/basic.py index bd4d2f9e..71e32f15 100644 --- a/powerline_shell/themes/basic.py +++ b/powerline_shell/themes/basic.py @@ -43,3 +43,7 @@ class Color(DefaultColor): TIME_FG = 8 TIME_BG = 7 + + KUBE_CONTEXT_FG = 14 + KUBE_CONTEXT_BG = 8 + diff --git a/powerline_shell/themes/default.py b/powerline_shell/themes/default.py index da0c0034..fa089ae2 100644 --- a/powerline_shell/themes/default.py +++ b/powerline_shell/themes/default.py @@ -75,6 +75,9 @@ class DefaultColor(object): TIME_FG = 250 TIME_BG = 238 + KUBE_CONTEXT_FG = 38 + KUBE_CONTEXT_BG = 239 + class Color(DefaultColor): """ diff --git a/powerline_shell/themes/gruvbox.py b/powerline_shell/themes/gruvbox.py index 1326ea46..e5b9a03d 100644 --- a/powerline_shell/themes/gruvbox.py +++ b/powerline_shell/themes/gruvbox.py @@ -109,3 +109,7 @@ class Color(DefaultColor): TIME_FG = light2 TIME_BG = dark4 + + KUBE_CONTEXT_FG = neutral_blue + KUBE_CONTEXT_BG = dark2 + diff --git a/powerline_shell/themes/solarized_dark.py b/powerline_shell/themes/solarized_dark.py index ec0f41bf..3f1dccb7 100644 --- a/powerline_shell/themes/solarized_dark.py +++ b/powerline_shell/themes/solarized_dark.py @@ -42,3 +42,7 @@ class Color(DefaultColor): TIME_FG = 15 TIME_BG = 10 + + KUBE_CONTEXT_FG = 7 + KUBE_CONTEXT_BG = 2 + diff --git a/powerline_shell/themes/washed.py b/powerline_shell/themes/washed.py index d2935095..19f06df1 100644 --- a/powerline_shell/themes/washed.py +++ b/powerline_shell/themes/washed.py @@ -42,3 +42,6 @@ class Color(DefaultColor): TIME_FG = 8 TIME_BG = 7 + + KUBE_CONTEXT_FG = 0 + KUBE_CONTEXT_BG = 7