Skip to content

Commit 03c8c64

Browse files
authored
[segment] added kubecontext segment
1 parent a9b8c9b commit 03c8c64

File tree

9 files changed

+172
-4
lines changed

9 files changed

+172
-4
lines changed

.gitignore

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,142 @@ config.json
99
powerline-shell.json
1010
.DS_Store
1111
*sublime*
12+
13+
# Byte-compiled / optimized / DLL files
14+
__pycache__/
15+
*.py[cod]
16+
*$py.class
17+
18+
# C extensions
19+
*.so
20+
21+
# Distribution / packaging
22+
.Python
23+
build/
24+
develop-eggs/
25+
dist/
26+
downloads/
27+
eggs/
28+
.eggs/
29+
lib/
30+
lib64/
31+
parts/
32+
sdist/
33+
var/
34+
wheels/
35+
share/python-wheels/
36+
*.egg-info/
37+
.installed.cfg
38+
*.egg
39+
MANIFEST
40+
41+
# PyInstaller
42+
# Usually these files are written by a python script from a template
43+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
44+
*.manifest
45+
*.spec
46+
47+
# Installer logs
48+
pip-log.txt
49+
pip-delete-this-directory.txt
50+
51+
# Unit test / coverage reports
52+
htmlcov/
53+
.tox/
54+
.nox/
55+
.coverage
56+
.coverage.*
57+
.cache
58+
nosetests.xml
59+
coverage.xml
60+
*.cover
61+
*.py,cover
62+
.hypothesis/
63+
.pytest_cache/
64+
cover/
65+
66+
# Translations
67+
*.mo
68+
*.pot
69+
70+
# Django stuff:
71+
*.log
72+
local_settings.py
73+
db.sqlite3
74+
db.sqlite3-journal
75+
76+
# Flask stuff:
77+
instance/
78+
.webassets-cache
79+
80+
# Scrapy stuff:
81+
.scrapy
82+
83+
# Sphinx documentation
84+
docs/_build/
85+
86+
# PyBuilder
87+
.pybuilder/
88+
target/
89+
90+
# Jupyter Notebook
91+
.ipynb_checkpoints
92+
93+
# IPython
94+
profile_default/
95+
ipython_config.py
96+
97+
# pyenv
98+
# For a library or package, you might want to ignore these files since the code is
99+
# intended to run in multiple environments; otherwise, check them in:
100+
# .python-version
101+
102+
# pipenv
103+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
104+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
105+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
106+
# install all needed dependencies.
107+
#Pipfile.lock
108+
109+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
110+
__pypackages__/
111+
112+
# Celery stuff
113+
celerybeat-schedule
114+
celerybeat.pid
115+
116+
# SageMath parsed files
117+
*.sage.py
118+
119+
# Environments
120+
.env
121+
.venv
122+
env/
123+
venv/
124+
ENV/
125+
env.bak/
126+
venv.bak/
127+
128+
# Spyder project settings
129+
.spyderproject
130+
.spyproject
131+
132+
# Rope project settings
133+
.ropeproject
134+
135+
# mkdocs documentation
136+
/site
137+
138+
# mypy
139+
.mypy_cache/
140+
.dmypy.json
141+
dmypy.json
142+
143+
# Pyre type checker
144+
.pyre/
145+
146+
# pytype static type analyzer
147+
.pytype/
148+
149+
# Cython debug symbols
150+
cython_debug/

powerline_shell/colortrans.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ def rgbstring2tuple(s):
106106
(95, 175, 215): 74,
107107
(95, 175, 255): 75,
108108
(95, 215, 0): 76,
109-
(95, 215, 95) : 77,
109+
(95, 215, 95): 77,
110110
(95, 215, 135): 78,
111111
(95, 215, 175): 79,
112112
(95, 215, 215): 80,
113113
(95, 215, 255): 81,
114114
(95, 255, 0): 82,
115-
(95, 255, 95) : 83,
115+
(95, 255, 95): 83,
116116
(95, 255, 135): 84,
117117
(95, 255, 175): 85,
118118
(95, 255, 215): 86,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
Shows the exported kubectl context
3+
e.g $ export KUBECONFIG=~/.kube/config-staging-cluster
4+
"""
5+
from ..utils import BasicSegment
6+
import os
7+
8+
9+
class Segment(BasicSegment):
10+
def add_to_powerline(self):
11+
kubecontext = os.environ.get("KUBECONFIG")
12+
if kubecontext:
13+
self.powerline.append(" kctx:%s " % os.path.basename(kubecontext),
14+
self.powerline.theme.KUBECONFIG_FG,
15+
self.powerline.theme.KUBECONFIG_BG)

powerline_shell/themes/basic.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ class Color(DefaultColor):
4343

4444
TIME_FG = 8
4545
TIME_BG = 7
46+
47+
KUBECONFIG_FG = 14
48+
KUBECONFIG_BG = 8

powerline_shell/themes/default.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ class DefaultColor(object):
7575
TIME_FG = 250
7676
TIME_BG = 238
7777

78+
KUBECONFIG_FG = 38
79+
KUBECONFIG_BG = 239
7880

7981
class Color(DefaultColor):
8082
"""

powerline_shell/themes/gruvbox.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,6 @@ class Color(DefaultColor):
109109

110110
TIME_FG = light2
111111
TIME_BG = dark4
112+
113+
KUBECONFIG_BG = neutral_blue
114+
KUBECONFIG_FG = dark2

powerline_shell/themes/solarized_dark.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ class Color(DefaultColor):
4242

4343
TIME_FG = 15
4444
TIME_BG = 10
45+
46+
KUBECONFIG_FG = 7
47+
KUBECONFIG_BG = 2

powerline_shell/themes/washed.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ class Color(DefaultColor):
4242

4343
TIME_FG = 8
4444
TIME_BG = 7
45+
46+
KUBECONFIG_FG = 0
47+
KUBECONFIG_BG = 7

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from setuptools import setup, find_packages
33

44
setup(
5-
name="powerline-shell",
5+
name="powerline-shell-test",
66
version="0.7.0",
77
description="A pretty prompt for your shell",
88
author="Buck Ryan",
@@ -27,6 +27,6 @@
2727
],
2828
entry_points="""
2929
[console_scripts]
30-
powerline-shell=powerline_shell:main
30+
powerline-shell-test=powerline_shell:main
3131
""",
3232
)

0 commit comments

Comments
 (0)