Compare commits

..
Author SHA1 Message Date
ohmyzsh[bot] f142aa12a5 chore(kube-ps1): update to 7aaaeee5 2026-09-27 06:28:41 +00:00
4 changed files with 42 additions and 23 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ dependencies:
plugins/kube-ps1:
repo: jonmosco/kube-ps1
branch: master
version: b4cd09ec8d4dc007173e28da40aeebf8eff8c87f
version: 7aaaeee5eaa29f920acd850ea63839d9f87b8ac5
precopy: |
set -e
find . ! -name kube-ps1.sh ! -name LICENSE ! -name README.md -delete
-2
View File
@@ -18,5 +18,3 @@ plugin is loaded, which is usually when you start up a new terminal emulator.
The cache is stored at:
- `$ZSH_CACHE_DIR/completions/_gh` completions script
If an update fails, the last successfully generated completion script is kept.
+2 -8
View File
@@ -13,12 +13,6 @@ fi
zmodload -F zsh/files b:zf_mv
() {
local completion_file="$ZSH_CACHE_DIR/completions/_gh"
local completion_tmp="${completion_file}.$$.${RANDOM}"
if gh completion --shell zsh >| "$completion_tmp" && [[ -s "$completion_tmp" ]]; then
zf_mv -f -- "$completion_tmp" "$completion_file"
fi
command rm -f -- "$completion_tmp"
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_gh"
zf_mv -f -- =( gh completion --shell zsh ) "$TMPPREFIX"
} &|
+39 -12
View File
@@ -39,6 +39,7 @@ KUBE_PS1_HIDE_IF_NOCONTEXT="${KUBE_PS1_HIDE_IF_NOCONTEXT:-false}"
_KUBE_PS1_KUBECONFIG_CACHE="${KUBECONFIG}"
_KUBE_PS1_DISABLE_PATH="${HOME}/.kube/kube-ps1/disabled"
_KUBE_PS1_LAST_TIME=0
_KUBE_PS1_HAS_CONTEXT=false
# Determine our shell
_kube_ps1_shell_type() {
@@ -264,15 +265,21 @@ _kube_ps1_prompt_update() {
[[ "${KUBE_PS1_ENABLED}" == "off" ]] && return $return_code
if ! _kube_ps1_binary_check "${KUBE_PS1_BINARY}"; then
# No ability to fetch context/namespace; display N/A.
# Unable to determine context availability; preserve the existing
# BINARY-N/A prompt instead of treating it as no context.
KUBE_PS1_CONTEXT="BINARY-N/A"
KUBE_PS1_NAMESPACE="N/A"
unset _KUBE_PS1_HAS_CONTEXT
# Refresh when the binary becomes available again.
_KUBE_PS1_LAST_TIME=0
return $return_code
fi
if [[ "${KUBECONFIG}" != "${_KUBE_PS1_KUBECONFIG_CACHE}" ]]; then
# User changed KUBECONFIG; unconditionally refetch.
_KUBE_PS1_KUBECONFIG_CACHE=${KUBECONFIG}
if [[ "${_KUBE_PS1_LAST_TIME}" == 0 ]] ||
[[ "${KUBECONFIG}" != "${_KUBE_PS1_KUBECONFIG_CACHE}" ]]; then
# Fetch initially, even if no config file exists, and whenever the
# user changes KUBECONFIG.
_KUBE_PS1_KUBECONFIG_CACHE="${KUBECONFIG}"
_kube_ps1_get_context_ns
return $return_code
fi
@@ -300,13 +307,30 @@ _kube_ps1_prompt_update() {
}
_kube_ps1_get_context() {
if [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]]; then
KUBE_PS1_CONTEXT="$(${KUBE_PS1_BINARY} config current-context 2>/dev/null)"
KUBE_PS1_CONTEXT="${KUBE_PS1_CONTEXT:-N/A}"
local context
if [[ -n "${KUBE_PS1_CLUSTER_FUNCTION}" ]]; then
KUBE_PS1_CONTEXT="$("${KUBE_PS1_CLUSTER_FUNCTION}" "${KUBE_PS1_CONTEXT}")"
fi
# Context availability must be detected even when context display is
# disabled but KUBE_PS1_HIDE_IF_NOCONTEXT is enabled.
if [[ "${KUBE_PS1_CONTEXT_ENABLE}" != true ]] &&
[[ "${KUBE_PS1_HIDE_IF_NOCONTEXT}" != true ]]; then
KUBE_PS1_CONTEXT=
return
fi
context="$("${KUBE_PS1_BINARY}" config current-context 2>/dev/null)"
_KUBE_PS1_HAS_CONTEXT=false
[[ -n "${context}" ]] && _KUBE_PS1_HAS_CONTEXT=true
if [[ "${KUBE_PS1_CONTEXT_ENABLE}" != true ]]; then
KUBE_PS1_CONTEXT=
return
fi
KUBE_PS1_CONTEXT="${context:-N/A}"
if [[ -n "${KUBE_PS1_CLUSTER_FUNCTION}" ]]; then
KUBE_PS1_CONTEXT="$("${KUBE_PS1_CLUSTER_FUNCTION}" "${KUBE_PS1_CONTEXT}")"
fi
}
@@ -325,7 +349,7 @@ _kube_ps1_get_context_ns() {
# Set the command time
if [[ "${_KUBE_PS1_SHELL}" == "bash" ]]; then
if ((BASH_VERSINFO[0] > 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 2))); then
_KUBE_PS1_LAST_TIME=$(printf '%(%s)T')
printf -v _KUBE_PS1_LAST_TIME '%(%s)T' -1
else
_KUBE_PS1_LAST_TIME=$(date +%s)
fi
@@ -407,8 +431,11 @@ kubeoff() {
# Build our prompt
kube_ps1() {
[[ "${KUBE_PS1_ENABLED}" == "off" ]] && return
[[ "${KUBE_PS1_HIDE_IF_NOCONTEXT}" == true ]] &&
[[ "${_KUBE_PS1_HAS_CONTEXT}" == false ]] && return
[[ -z "${KUBE_PS1_CONTEXT}" ]] && [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]] && return
[[ "${KUBE_PS1_CONTEXT}" == "N/A" ]] && [[ ${KUBE_PS1_HIDE_IF_NOCONTEXT} == true ]] && return
local KUBE_PS1
local KUBE_PS1_RESET_COLOR="${_KUBE_PS1_OPEN_ESC}${_KUBE_PS1_DEFAULT_FG}${_KUBE_PS1_CLOSE_ESC}"