mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-12-18 05:40:07 +00:00
Merge branch 'next' into next
This commit is contained in:
commit
e09d4ae926
6 changed files with 126 additions and 0 deletions
|
@ -28,3 +28,4 @@ script:
|
||||||
- test/segments/rust_version.spec
|
- test/segments/rust_version.spec
|
||||||
- test/segments/go_version.spec
|
- test/segments/go_version.spec
|
||||||
- test/segments/vcs.spec
|
- test/segments/vcs.spec
|
||||||
|
- test/segments/kubecontext.spec
|
||||||
|
|
22
CHANGELOG.md
22
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
|
## v0.6.4
|
||||||
|
|
||||||
- Significant enhancements to the `battery` segment. Check out the README to
|
- Significant enhancements to the `battery` segment. Check out the README to
|
||||||
|
|
|
@ -139,6 +139,7 @@ The segments that are currently available are:
|
||||||
* [`aws`](#aws) - The current AWS profile, if active.
|
* [`aws`](#aws) - The current AWS profile, if active.
|
||||||
* `aws_eb_env` - The current Elastic Beanstalk Environment.
|
* `aws_eb_env` - The current Elastic Beanstalk Environment.
|
||||||
* `docker_machine` - The current Docker Machine.
|
* `docker_machine` - The current Docker Machine.
|
||||||
|
* `kubecontext` - The current context of your `kubectl` configuration.
|
||||||
|
|
||||||
**Other:**
|
**Other:**
|
||||||
* [`custom_command`](#custom_command) - Create a custom segment to display the
|
* [`custom_command`](#custom_command) - Create a custom segment to display the
|
||||||
|
|
|
@ -85,6 +85,7 @@ case $POWERLEVEL9K_MODE in
|
||||||
EXECUTION_TIME_ICON $'\UE89C' #
|
EXECUTION_TIME_ICON $'\UE89C' #
|
||||||
SSH_ICON '(ssh)'
|
SSH_ICON '(ssh)'
|
||||||
VPN_ICON '(vpn)'
|
VPN_ICON '(vpn)'
|
||||||
|
KUBERNETES_ICON $'\U2388' # ⎈
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
'awesome-fontconfig')
|
'awesome-fontconfig')
|
||||||
|
@ -154,6 +155,7 @@ case $POWERLEVEL9K_MODE in
|
||||||
EXECUTION_TIME_ICON $'\uF253'
|
EXECUTION_TIME_ICON $'\uF253'
|
||||||
SSH_ICON '(ssh)'
|
SSH_ICON '(ssh)'
|
||||||
VPN_ICON $'\uF023'
|
VPN_ICON $'\uF023'
|
||||||
|
KUBERNETES_ICON $'\U2388' # ⎈
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
'nerdfont-complete'|'nerdfont-fontconfig')
|
'nerdfont-complete'|'nerdfont-fontconfig')
|
||||||
|
@ -223,6 +225,7 @@ case $POWERLEVEL9K_MODE in
|
||||||
EXECUTION_TIME_ICON $'\uF252' #
|
EXECUTION_TIME_ICON $'\uF252' #
|
||||||
SSH_ICON $'\uF489' #
|
SSH_ICON $'\uF489' #
|
||||||
VPN_ICON '(vpn)'
|
VPN_ICON '(vpn)'
|
||||||
|
KUBERNETES_ICON $'\U2388' # ⎈
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -292,6 +295,7 @@ case $POWERLEVEL9K_MODE in
|
||||||
EXECUTION_TIME_ICON 'Dur'
|
EXECUTION_TIME_ICON 'Dur'
|
||||||
SSH_ICON '(ssh)'
|
SSH_ICON '(ssh)'
|
||||||
VPN_ICON '(vpn)'
|
VPN_ICON '(vpn)'
|
||||||
|
KUBERNETES_ICON $'\U2388' # ⎈
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -1364,6 +1364,24 @@ prompt_dir_writable() {
|
||||||
fi
|
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
|
# Prompt processing and drawing
|
||||||
################################################################
|
################################################################
|
||||||
|
|
80
test/segments/kubecontext.spec
Executable file
80
test/segments/kubecontext.spec
Executable file
|
@ -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
|
Loading…
Reference in a new issue