summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Hilburn <bhilburn@gmail.com>2017-06-02 19:09:35 +0300
committerGitHub <noreply@github.com>2017-06-02 19:09:35 +0300
commite09d4ae92600bc4c567d0c0d19dfc5139416561a (patch)
treebe6fb9608198c083c0c845eda2a11117c03213a9
parent5eec2e28d0e44b2ac168fc3e08a38d68d4cb4fbe (diff)
parentd6a14a9a010009866c60a2f4d52d0aefac93e876 (diff)
Merge branch 'next' into next
-rw-r--r--.travis.yml1
-rw-r--r--CHANGELOG.md22
-rw-r--r--README.md1
-rw-r--r--functions/icons.zsh4
-rwxr-xr-xpowerlevel9k.zsh-theme18
-rwxr-xr-xtest/segments/kubecontext.spec80
6 files changed, 126 insertions, 0 deletions
diff --git a/.travis.yml b/.travis.yml
index 134f31f1..e0ad5a93 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -28,3 +28,4 @@ script:
- test/segments/rust_version.spec
- test/segments/go_version.spec
- test/segments/vcs.spec
+ - test/segments/kubecontext.spec
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7d6ecd18..0355c464 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,25 @@
+## Next
+
+- Added `teardown` command to turn off P9k prompt.
+- Fixes for P9k in Cygwin and 32-bit systems.
+- Better colors in virtualization segments.
+- Added 'Gopher' icon to the `go_version` segment.
+- Improved detection in `nvm`
+- Added option to support command status reading from piped command sequences.
+
+### New Segments: `host` and `user`
+
+Provides two separate segments for `host` and `user` in case you don't wont both
+in one (per the `context` segment).
+
+### New Segment: `newline`
+
+Allows you to split segments across multiple lines.
+
+### New Segment: `kubecontext`
+
+Shows the current context of your `kubectl` configuration.
+
## v0.6.4
- Significant enhancements to the `battery` segment. Check out the README to
diff --git a/README.md b/README.md
index 5b9cb24a..b03bee48 100644
--- a/README.md
+++ b/README.md
@@ -139,6 +139,7 @@ The segments that are currently available are:
* [`aws`](#aws) - The current AWS profile, if active.
* `aws_eb_env` - The current Elastic Beanstalk Environment.
* `docker_machine` - The current Docker Machine.
+* `kubecontext` - The current context of your `kubectl` configuration.
**Other:**
* [`custom_command`](#custom_command) - Create a custom segment to display the
diff --git a/functions/icons.zsh b/functions/icons.zsh
index 9b5953e3..ea9d959b 100644
--- a/functions/icons.zsh
+++ b/functions/icons.zsh
@@ -85,6 +85,7 @@ case $POWERLEVEL9K_MODE in
EXECUTION_TIME_ICON $'\UE89C' # 
SSH_ICON '(ssh)'
VPN_ICON '(vpn)'
+ KUBERNETES_ICON $'\U2388' # ⎈
)
;;
'awesome-fontconfig')
@@ -154,6 +155,7 @@ case $POWERLEVEL9K_MODE in
EXECUTION_TIME_ICON $'\uF253'
SSH_ICON '(ssh)'
VPN_ICON $'\uF023'
+ KUBERNETES_ICON $'\U2388' # ⎈
)
;;
'nerdfont-complete'|'nerdfont-fontconfig')
@@ -223,6 +225,7 @@ case $POWERLEVEL9K_MODE in
EXECUTION_TIME_ICON $'\uF252' # 
SSH_ICON $'\uF489' # 
VPN_ICON '(vpn)'
+ KUBERNETES_ICON $'\U2388' # ⎈
)
;;
*)
@@ -292,6 +295,7 @@ case $POWERLEVEL9K_MODE in
EXECUTION_TIME_ICON 'Dur'
SSH_ICON '(ssh)'
VPN_ICON '(vpn)'
+ KUBERNETES_ICON $'\U2388' # ⎈
)
;;
esac
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 760de5a9..dc7f0388 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -1364,6 +1364,24 @@ prompt_dir_writable() {
fi
}
+# Kubernetes Current Context
+prompt_kubecontext() {
+ local kubectl_version=$(kubectl version 2>/dev/null)
+
+ if [[ -n "$kubectl_version" ]]; then
+ # Get the current Kubernetes config context's namespaece
+ local k8s_namespace=$(kubectl config get-contexts --no-headers | grep '*' | awk '{print $5}')
+ # Get the current Kuberenetes context
+ local k8s_context=$(kubectl config current-context)
+
+ if [[ -z "$k8s_namespace" ]]; then
+ k8s_namespace="default"
+ fi
+ "$1_prompt_segment" "$0" "$2" "magenta" "white" "$k8s_context/$k8s_namespace" "KUBERNETES_ICON"
+ fi
+}
+
+
################################################################
# Prompt processing and drawing
################################################################
diff --git a/test/segments/kubecontext.spec b/test/segments/kubecontext.spec
new file mode 100755
index 00000000..eaaa2300
--- /dev/null
+++ b/test/segments/kubecontext.spec
@@ -0,0 +1,80 @@
+#!/usr/bin/env zsh
+#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
+
+# Required for shunit2 to run correctly
+setopt shwordsplit
+SHUNIT_PARENT=$0
+
+function setUp() {
+ export TERM="xterm-256color"
+ # Load Powerlevel9k
+ source powerlevel9k.zsh-theme
+}
+
+function mockKubectl() {
+ case "$1" in
+ 'version')
+ echo 'non-empty text'
+ ;;
+ 'config')
+ case "$2" in
+ 'current-context')
+ echo 'minikube'
+ ;;
+ 'get-contexts')
+ echo '* minikube minikube minikube '
+ ;;
+ esac
+ ;;
+ esac
+}
+
+function mockKubectlOtherNamespace() {
+ case "$1" in
+ 'version')
+ echo 'non-empty text'
+ ;;
+ 'config')
+ case "$2" in
+ 'current-context')
+ echo 'minikube'
+ ;;
+ 'get-contexts')
+ echo '* minikube minikube minikube kube-system'
+ ;;
+ esac
+ ;;
+ esac
+}
+
+function testKubeContext() {
+ alias kubectl=mockKubectl
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext)
+
+ assertEquals "%K{magenta} %F{white%}⎈%f %F{white}minikube/default %k%F{magenta}%f " "$(build_left_prompt)"
+
+ unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ unalias kubectl
+}
+function testKubeContextOtherNamespace() {
+ alias kubectl=mockKubectlOtherNamespace
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext)
+
+ assertEquals "%K{magenta} %F{white%}⎈%f %F{white}minikube/kube-system %k%F{magenta}%f " "$(build_left_prompt)"
+
+ unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ unalias kubectl
+}
+function testKubeContextPrintsNothingIfKubectlNotAvailable() {
+ alias kubectl=noKubectl
+ POWERLEVEL9K_CUSTOM_WORLD='echo world'
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world kubecontext)
+
+ assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
+
+ unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ unset POWERLEVEL9K_CUSTOM_WORLD
+ unalias kubectl
+}
+
+source shunit2/source/2.1/src/shunit2