diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 51d5f359..e4879f3c 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -336,6 +336,10 @@ function ruby_version_prompt { echo -e "$(rbfu_version_prompt)$(rbenv_version_prompt)$(rvm_version_prompt)$(chruby_version_prompt)" } +function k8s_context_prompt { + echo -e "$(kubectl config current-context)" +} + function virtualenv_prompt { if [[ -n "$VIRTUAL_ENV" ]]; then virtualenv=`basename "$VIRTUAL_ENV"` diff --git a/themes/powerline-naked/README.md b/themes/powerline-naked/README.md index 62238bd5..da5e254b 100644 --- a/themes/powerline-naked/README.md +++ b/themes/powerline-naked/README.md @@ -14,6 +14,7 @@ A colorful theme, where shows a lot information about your shell session. * An indicator when the current shell is inside the Vim editor * Battery charging status (depends on the [../../plugins/available/battery.plugin.bash](battery plugin)) * SCM Repository status (e.g. Git, SVN) +* The current Kubernetes environment * The current Python environment (Virtualenv, venv, and Conda are supported) in use * The current Ruby environment (rvm and rbenv are supported) in use * Last command exit code (only shown when the exit code is greater than 0) @@ -48,11 +49,12 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o * `cwd` - Current working directory including full folder hierarchy (c.f. `wd`) * `hostname` - Host name of machine * `in_vim` - Show identifier if running in `:terminal` from vim +* `k8s_context` - Show current kubernetes context * `last_status` - Exit status of last run command * `python_venv` - Python virtual environment information (`virtualenv`, `venv` and `conda` supported) * `ruby` - Current ruby version if using `rvm` -* `scm` - Version control information, `git` +* `scm` - Version control information, `git` * `user_info` - Current user * `wd` - Working directory, like `cwd` but doesn't show the full folder hierarchy, only the directory you're currently in. diff --git a/themes/powerline-naked/powerline-naked.theme.bash b/themes/powerline-naked/powerline-naked.theme.bash index 4e06273c..81025c84 100644 --- a/themes/powerline-naked/powerline-naked.theme.bash +++ b/themes/powerline-naked/powerline-naked.theme.bash @@ -33,6 +33,9 @@ RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "} +KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "} +KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=26 + AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=❲aws❳ }" AWS_PROFILE_PROMPT_COLOR=208 diff --git a/themes/powerline-plain/README.md b/themes/powerline-plain/README.md index ef773cd8..701b9fa1 100644 --- a/themes/powerline-plain/README.md +++ b/themes/powerline-plain/README.md @@ -12,6 +12,7 @@ A colorful theme, where shows a lot information about your shell session. * An indicator when the current shell is inside the Vim editor * Battery charging status (depends on the [../../plugins/available/battery.plugin.bash](battery plugin)) * SCM Repository status (e.g. Git, SVN) +* The current Kubernetes environment * The current Python environment (Virtualenv, venv, and Conda are supported) in use * The current Ruby environment (rvm and rbenv are supported) in use * Last command exit code (only shown when the exit code is greater than 0) @@ -46,11 +47,12 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o * `cwd` - Current working directory including full folder hierarchy (c.f. `wd`) * `hostname` - Host name of machine * `in_vim` - Show identifier if running in `:terminal` from vim +* `k8s_context` - Show current kubernetes context * `last_status` - Exit status of last run command * `python_venv` - Python virtual environment information (`virtualenv`, `venv` and `conda` supported) * `ruby` - Current ruby version if using `rvm` -* `scm` - Version control information, `git` +* `scm` - Version control information, `git` * `user_info` - Current user * `wd` - Working directory, like `cwd` but doesn't show the full folder hierarchy, only the directory you're currently in. diff --git a/themes/powerline-plain/powerline-plain.theme.bash b/themes/powerline-plain/powerline-plain.theme.bash index 0757dc9e..bddb6450 100644 --- a/themes/powerline-plain/powerline-plain.theme.bash +++ b/themes/powerline-plain/powerline-plain.theme.bash @@ -28,6 +28,9 @@ RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="💎 "} +KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "} +KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=26 + AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=❲aws❳ }" AWS_PROFILE_PROMPT_COLOR=208 diff --git a/themes/powerline/README.md b/themes/powerline/README.md index d3f7fbca..974bcbeb 100644 --- a/themes/powerline/README.md +++ b/themes/powerline/README.md @@ -16,6 +16,7 @@ A colorful theme, where shows a lot information about your shell session. * An indicator when the current shell is inside the Vim editor * Battery charging status (depends on the [../../plugins/available/battery.plugin.bash](battery plugin)) * SCM Repository status (e.g. Git, SVN) +* The current Kubernetes environment * The current Python environment (Virtualenv, venv, and Conda are supported) in use * The current Ruby environment (rvm and rbenv are supported) in use * Last command exit code (only shown when the exit code is greater than 0) @@ -50,11 +51,12 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o * `cwd` - Current working directory including full folder hierarchy (c.f. `wd`) * `hostname` - Host name of machine * `in_vim` - Show identifier if running in `:terminal` from vim +* `k8s_context` - Show current kubernetes context * `last_status` - Exit status of last run command * `python_venv` - Python virtual environment information (`virtualenv`, `venv` and `conda` supported) * `ruby` - Current ruby version if using `rvm` -* `scm` - Version control information, `git` +* `scm` - Version control information, `git` * `user_info` - Current user * `wd` - Working directory, like `cwd` but doesn't show the full folder hierarchy, only the directory you're currently in. diff --git a/themes/powerline/powerline.base.bash b/themes/powerline/powerline.base.bash index 7dded057..08da5f7c 100644 --- a/themes/powerline/powerline.base.bash +++ b/themes/powerline/powerline.base.bash @@ -52,6 +52,16 @@ function __powerline_ruby_prompt { [[ -n "${ruby_version}" ]] && echo "${RUBY_CHAR}${ruby_version}|${RUBY_THEME_PROMPT_COLOR}" } +function __powerline_k8s_context_prompt { + local kubernetes_context="" + + if _command_exists kubectl; then + kubernetes_context="$(k8s_context_prompt)" + fi + + [[ -n "${kubernetes_context}" ]] && echo "${KUBERNETES_CONTEXT_THEME_CHAR}${kubernetes_context}|${KUBERNETES_CONTEXT_THEME_PROMPT_COLOR}" +} + function __powerline_python_venv_prompt { set +u local python_venv="" diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash index 9f0e6f04..482b3464 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -31,6 +31,9 @@ RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "} +KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "} +KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=26 + AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=❲aws❳ }" AWS_PROFILE_PROMPT_COLOR=208