f0e2160abb4a08986fc8f5e05dadfcfdd91cf3de

Author
ohmyzsh[bot] <54982679+ohmyzsh[bot]@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date

Message

chore(kube-ps1): update to e19c9ee8 (#13666)

Co-authored-by: ohmyzsh[bot] <54982679+ohmyzsh[bot]@users.noreply.github.com>

Diff

  1diff --git a/.github/dependencies.yml b/.github/dependencies.yml
  2index 4f4fef93bceb50432d6430b91b9c5de3640658ed..ff239c657e6cea7c275dd7fe73b7e615f9cdac9d 100644
  3--- a/.github/dependencies.yml
  4+++ b/.github/dependencies.yml
  5@@ -30,7 +30,7 @@ dependencies:
  6   plugins/kube-ps1:
  7     repo: jonmosco/kube-ps1
  8     branch: master
  9-    version: 9b41c091d5dd4a99e58cf58b5d98a4847937b1bb
 10+    version: e19c9ee867c5655814c384a6bf543e330e6ef1b7
 11     precopy: |
 12       set -e
 13       find . ! -name kube-ps1.sh ! -name LICENSE ! -name README.md -delete
 14diff --git a/plugins/kube-ps1/kube-ps1.plugin.zsh b/plugins/kube-ps1/kube-ps1.plugin.zsh
 15index 9dcd6da44f1246494663d7d175eb288bc586bf3c..f59b92df9dee181f0ba8b08656d011d9f4933936 100644
 16--- a/plugins/kube-ps1/kube-ps1.plugin.zsh
 17+++ b/plugins/kube-ps1/kube-ps1.plugin.zsh
 18@@ -55,7 +55,17 @@ _kube_ps1_shell_type() {
 19 _kube_ps1_init() {
 20   [[ -f "${_KUBE_PS1_DISABLE_PATH}" ]] && KUBE_PS1_ENABLED=off
 21 
 22-  case "$(_kube_ps1_shell_type)" in
 23+  # Detect shell type once and cache it
 24+  _KUBE_PS1_SHELL="$(_kube_ps1_shell_type)"
 25+
 26+  # Check tput availability once
 27+  if tput setaf 1 &> /dev/null; then
 28+    _KUBE_PS1_TPUT_AVAILABLE=true
 29+  else
 30+    _KUBE_PS1_TPUT_AVAILABLE=false
 31+  fi
 32+
 33+  case "${_KUBE_PS1_SHELL}" in
 34     "zsh")
 35       _KUBE_PS1_OPEN_ESC="%{"
 36       _KUBE_PS1_CLOSE_ESC="%}"
 37@@ -96,10 +106,10 @@ _kube_ps1_color_fg() {
 38   if [[ "${_KUBE_PS1_FG_CODE}" == "default" ]]; then
 39     _KUBE_PS1_FG_CODE="${_KUBE_PS1_DEFAULT_FG}"
 40     return
 41-  elif [[ "$(_kube_ps1_shell_type)" == "zsh" ]]; then
 42+  elif [[ "${_KUBE_PS1_SHELL}" == "zsh" ]]; then
 43     _KUBE_PS1_FG_CODE="%F{$_KUBE_PS1_FG_CODE}"
 44-  elif [[ "$(_kube_ps1_shell_type)" == "bash" ]]; then
 45-    if tput setaf 1 &> /dev/null; then
 46+  elif [[ "${_KUBE_PS1_SHELL}" == "bash" ]]; then
 47+    if [[ "${_KUBE_PS1_TPUT_AVAILABLE}" == "true" ]]; then
 48       _KUBE_PS1_FG_CODE="$(tput setaf "${_KUBE_PS1_FG_CODE}")"
 49     elif [[ $_KUBE_PS1_FG_CODE -ge 0 ]] && [[ $_KUBE_PS1_FG_CODE -le 256 ]]; then
 50       _KUBE_PS1_FG_CODE="\033[38;5;${_KUBE_PS1_FG_CODE}m"
 51@@ -129,15 +139,15 @@ _kube_ps1_color_bg() {
 52   if [[ "${_KUBE_PS1_BG_CODE}" == "default" ]]; then
 53     _KUBE_PS1_FG_CODE="${_KUBE_PS1_DEFAULT_BG}"
 54     return
 55-  elif [[ "$(_kube_ps1_shell_type)" == "zsh" ]]; then
 56+  elif [[ "${_KUBE_PS1_SHELL}" == "zsh" ]]; then
 57     _KUBE_PS1_BG_CODE="%K{$_KUBE_PS1_BG_CODE}"
 58-  elif [[ "$(_kube_ps1_shell_type)" == "bash" ]]; then
 59-    if tput setaf 1 &> /dev/null; then
 60+  elif [[ "${_KUBE_PS1_SHELL}" == "bash" ]]; then
 61+    if [[ "${_KUBE_PS1_TPUT_AVAILABLE}" == "true" ]]; then
 62       _KUBE_PS1_BG_CODE="$(tput setab "${_KUBE_PS1_BG_CODE}")"
 63     elif [[ $_KUBE_PS1_BG_CODE -ge 0 ]] && [[ $_KUBE_PS1_BG_CODE -le 256 ]]; then
 64       _KUBE_PS1_BG_CODE="\033[48;5;${_KUBE_PS1_BG_CODE}m"
 65     else
 66-      _KUBE_PS1_BG_CODE="${DEFAULT_BG}"
 67+      _KUBE_PS1_BG_CODE="${_KUBE_PS1_DEFAULT_BG}"
 68     fi
 69   fi
 70   echo "${_KUBE_PS1_OPEN_ESC}${_KUBE_PS1_BG_CODE}${_KUBE_PS1_CLOSE_ESC}"
 71@@ -174,7 +184,7 @@ _kube_ps1_symbol() {
 72       symbol="$(_kube_ps1_color_fg ${oc_symbol_color})${oc_glyph}${KUBE_PS1_RESET_COLOR}"
 73       ;;
 74     *)
 75-      case "$(_kube_ps1_shell_type)" in
 76+      case "${_KUBE_PS1_SHELL}" in
 77         bash)
 78           if ((BASH_VERSINFO[0] >= 4)) && [[ $'\u2388' != "\\u2388" ]]; then
 79             symbol="$(_kube_ps1_color_fg $custom_symbol_color)${symbol_default}${KUBE_PS1_RESET_COLOR}"
 80@@ -212,7 +222,7 @@ _kube_ps1_file_newer_than() {
 81   local file=$1
 82   local check_time=$2
 83 
 84-  if [[ "$(_kube_ps1_shell_type)" == "zsh" ]]; then
 85+  if [[ "${_KUBE_PS1_SHELL}" == "zsh" ]]; then
 86     # Use zstat '-F %s.%s' to make it compatible with low zsh version (eg: 5.0.2)
 87     mtime=$(zstat -L +mtime -F %s.%s "${file}")
 88   elif stat -c "%s" /dev/null &> /dev/null; then
 89@@ -292,13 +302,13 @@ _kube_ps1_get_ns() {
 90 
 91 _kube_ps1_get_context_ns() {
 92   # Set the command time
 93-  if [[ "$(_kube_ps1_shell_type)" == "bash" ]]; then
 94+  if [[ "${_KUBE_PS1_SHELL}" == "bash" ]]; then
 95     if ((BASH_VERSINFO[0] >= 4 && BASH_VERSINFO[1] >= 2)); then
 96       _KUBE_PS1_LAST_TIME=$(printf '%(%s)T')
 97     else
 98       _KUBE_PS1_LAST_TIME=$(date +%s)
 99     fi
100-  elif [[ "$(_kube_ps1_shell_type)" == "zsh" ]]; then
101+  elif [[ "${_KUBE_PS1_SHELL}" == "zsh" ]]; then
102     _KUBE_PS1_LAST_TIME=$EPOCHREALTIME
103   fi
104 
105@@ -325,7 +335,7 @@ Toggle kube-ps1 prompt on
106 
107 Usage: kubeon [-g | --global] [-h | --help]
108 
109-With no arguments, turn oon kube-ps1 status for this shell instance (default).
110+With no arguments, turn on kube-ps1 status for this shell instance (default).
111 
112   -g --global  turn on kube-ps1 status globally
113   -h --help    print this message