mirror of
https://github.com/b-ryan/powerline-shell.git
synced 2026-09-10 07:26:28 -04:00
[segment] added kubecontext segment
This commit is contained in:
parent
a9b8c9bb39
commit
03c8c6427a
139
.gitignore
vendored
139
.gitignore
vendored
|
|
@ -9,3 +9,142 @@ config.json
|
|||
powerline-shell.json
|
||||
.DS_Store
|
||||
*sublime*
|
||||
|
||||
# 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
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
|
|
|||
15
powerline_shell/segments/kubecontext.py
Normal file
15
powerline_shell/segments/kubecontext.py
Normal file
|
|
@ -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):
|
||||
kubecontext = os.environ.get("KUBECONFIG")
|
||||
if kubecontext:
|
||||
self.powerline.append(" kctx:%s " % os.path.basename(kubecontext),
|
||||
self.powerline.theme.KUBECONFIG_FG,
|
||||
self.powerline.theme.KUBECONFIG_BG)
|
||||
|
|
@ -43,3 +43,6 @@ class Color(DefaultColor):
|
|||
|
||||
TIME_FG = 8
|
||||
TIME_BG = 7
|
||||
|
||||
KUBECONFIG_FG = 14
|
||||
KUBECONFIG_BG = 8
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ class DefaultColor(object):
|
|||
TIME_FG = 250
|
||||
TIME_BG = 238
|
||||
|
||||
KUBECONFIG_FG = 38
|
||||
KUBECONFIG_BG = 239
|
||||
|
||||
class Color(DefaultColor):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -109,3 +109,6 @@ class Color(DefaultColor):
|
|||
|
||||
TIME_FG = light2
|
||||
TIME_BG = dark4
|
||||
|
||||
KUBECONFIG_BG = neutral_blue
|
||||
KUBECONFIG_FG = dark2
|
||||
|
|
|
|||
|
|
@ -42,3 +42,6 @@ class Color(DefaultColor):
|
|||
|
||||
TIME_FG = 15
|
||||
TIME_BG = 10
|
||||
|
||||
KUBECONFIG_FG = 7
|
||||
KUBECONFIG_BG = 2
|
||||
|
|
|
|||
|
|
@ -42,3 +42,6 @@ class Color(DefaultColor):
|
|||
|
||||
TIME_FG = 8
|
||||
TIME_BG = 7
|
||||
|
||||
KUBECONFIG_FG = 0
|
||||
KUBECONFIG_BG = 7
|
||||
|
|
|
|||
4
setup.py
4
setup.py
|
|
@ -2,7 +2,7 @@
|
|||
from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name="powerline-shell",
|
||||
name="powerline-shell-test",
|
||||
version="0.7.0",
|
||||
description="A pretty prompt for your shell",
|
||||
author="Buck Ryan",
|
||||
|
|
@ -27,6 +27,6 @@ setup(
|
|||
],
|
||||
entry_points="""
|
||||
[console_scripts]
|
||||
powerline-shell=powerline_shell:main
|
||||
powerline-shell-test=powerline_shell:main
|
||||
""",
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue