Skip to content

Commit

Permalink
[segment] added kubecontext segment
Browse files Browse the repository at this point in the history
[segment] added kubecontext segement
  • Loading branch information
sandjaie committed Aug 1, 2020
1 parent a9b8c9b commit 1a1fedd
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 3 deletions.
59 changes: 59 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,63 @@ 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/

__pypackages__/

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
6 changes: 3 additions & 3 deletions powerline_shell/colortrans.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 15 additions & 0 deletions powerline_shell/segments/kubecontext.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
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 kubecontext:
self.powerline.append(" kctx:%s " % os.path.basename(kube_context),
self.powerline.theme.KUBE_CONTEXT_FG,
self.powerline.theme.KUBE_CONTEXT_BG)
3 changes: 3 additions & 0 deletions powerline_shell/themes/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ class Color(DefaultColor):

TIME_FG = 8
TIME_BG = 7

KUBE_CONTEXT_FG = 14
KUBE_CONTEXT_BG = 8
2 changes: 2 additions & 0 deletions powerline_shell/themes/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class DefaultColor(object):
TIME_FG = 250
TIME_BG = 238

KUBE_CONTEXT_FG = 38
KUBE_CONTEXT_BG = 239

class Color(DefaultColor):
"""
Expand Down
3 changes: 3 additions & 0 deletions powerline_shell/themes/gruvbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,6 @@ class Color(DefaultColor):

TIME_FG = light2
TIME_BG = dark4

KUBE_CONTEXT_FG = neutral_blue
KUBE_CONTEXT_BG = dark2
3 changes: 3 additions & 0 deletions powerline_shell/themes/solarized_dark.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ class Color(DefaultColor):

TIME_FG = 15
TIME_BG = 10

KUBE_CONTEXT_FG = 7
KUBE_CONTEXT_BG = 2
3 changes: 3 additions & 0 deletions powerline_shell/themes/washed.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ class Color(DefaultColor):

TIME_FG = 8
TIME_BG = 7

KUBE_CONTEXT_FG = 0
KUBE_CONTEXT_BG = 7

0 comments on commit 1a1fedd

Please sign in to comment.