72b8f0b73b56b4a5c01eada3cb93b94be39fd984

Author
Marc Cornellà <hello@mcornella.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

fix(half-life): fix prompt color bleeding and code clean up (#10085)

Fixes #10085
Closes #10223

Co-authored-by: valdaarhun <icegambit91@gmail.com>

Diff

This diff is truncated to protect this page.

  1diff --git a/themes/half-life.zsh-theme b/themes/half-life.zsh-theme
  2index c79027ed61e9fd6759b8431b6c21adbe4fbac119..c4d785126794214606a9c5e2bab40aa6625e9137 100644
  3--- a/themes/half-life.zsh-theme
  4+++ b/themes/half-life.zsh-theme
  5@@ -7,31 +7,22 @@
  6 # git untracked files modification from Brian Carper:
  7 # https://briancarper.net/blog/570/git-info-in-your-zsh-prompt
  8 
  9-function virtualenv_info {
 10-    [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
 11-}
 12-PR_GIT_UPDATE=1
 13-
 14-setopt prompt_subst
 15-
 16-autoload -U add-zsh-hook
 17-autoload -Uz vcs_info
 18-
 19 #use extended color palette if available
 20-if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then
 21-    turquoise="%F{81}"
 22-    orange="%F{166}"
 23-    purple="%F{135}"
 24-    hotpink="%F{161}"
 25-    limegreen="%F{118}"
 26+if [[ $TERM = (*256color|*rxvt*) ]]; then
 27+  turquoise="%{${(%):-"%F{81}"}%}"
 28+  orange="%{${(%):-"%F{166}"}%}"
 29+  purple="%{${(%):-"%F{135}"}%}"
 30+  hotpink="%{${(%):-"%F{161}"}%}"
 31+  limegreen="%{${(%):-"%F{118}"}%}"
 32 else
 33-    turquoise="$fg[cyan]"
 34-    orange="$fg[yellow]"
 35-    purple="$fg[magenta]"
 36-    hotpink="$fg[red]"
 37-    limegreen="$fg[green]"
 38+  turquoise="%{${(%):-"%F{cyan}"}%}"
 39+  orange="%{${(%):-"%F{yellow}"}%}"
 40+  purple="%{${(%):-"%F{magenta}"}%}"
 41+  hotpink="%{${(%):-"%F{red}"}%}"
 42+  limegreen="%{${(%):-"%F{green}"}%}"
 43 fi
 44 
 45+autoload -Uz vcs_info
 46 # enable VCS systems you use
 47 zstyle ':vcs_info:*' enable git svn
 48 
 49@@ -47,10 +38,10 @@ zstyle ':vcs_info:*:prompt:*' check-for-changes true
 50 # %R - repository path
 51 # %S - path in the repository
 52 PR_RST="%{${reset_color}%}"
 53-FMT_BRANCH=" on %{$turquoise%}%b%u%c${PR_RST}"
 54-FMT_ACTION=" performing a %{$limegreen%}%a${PR_RST}"
 55-FMT_UNSTAGED="%{$orange%} ●"
 56-FMT_STAGED="%{$limegreen%} ●"
 57+FMT_BRANCH=" on ${turquoise}%b%u%c${PR_RST}"
 58+FMT_ACTION=" performing a ${limegreen}%a${PR_RST}"
 59+FMT_UNSTAGED="${orange} ●"
 60+FMT_STAGED="${limegreen} ●"
 61 
 62 zstyle ':vcs_info:*:prompt:*' unstagedstr   "${FMT_UNSTAGED}"
 63 zstyle ':vcs_info:*:prompt:*' stagedstr     "${FMT_STAGED}"
 64@@ -59,38 +50,44 @@ zstyle ':vcs_info:*:prompt:*' formats       "${FMT_BRANCH}"
 65 zstyle ':vcs_info:*:prompt:*' nvcsformats   ""
 66 
 67 
 68-function steeef_preexec {
 69-    case "$2" in
 70-        *git*)
 71-            PR_GIT_UPDATE=1
 72-            ;;
 73-        *svn*)
 74-            PR_GIT_UPDATE=1
 75-            ;;
 76-    esac
 77+function steeef_chpwd {
 78+  PR_GIT_UPDATE=1
 79 }
 80-add-zsh-hook preexec steeef_preexec
 81 
 82-function steeef_chpwd {
 83-    PR_GIT_UPDATE=1
 84+function steeef_preexec {
 85+  case "$2" in
 86+  *git*|*svn*) PR_GIT_UPDATE=1 ;;
 87+  esac
 88 }
 89-add-zsh-hook chpwd steeef_chpwd
 90 
 91 function steeef_precmd {
 92-    if [[ -n "$PR_GIT_UPDATE" ]] ; then
 93-        # check for untracked files or updated submodules, since vcs_info doesn't
 94-        if [[ ! -z $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
 95-            PR_GIT_UPDATE=1
 96-            FMT_BRANCH="${PM_RST} on %{$turquoise%}%b%u%c%{$hotpink%} ●${PR_RST}"
 97-        else
 98-            FMT_BRANCH="${PM_RST} on %{$turquoise%}%b%u%c${PR_RST}"
 99-        fi
100-        zstyle ':vcs_info:*:prompt:*' formats       "${FMT_BRANCH}"
101+  (( PR_GIT_UPDATE )) || return
102 
103-        vcs_info 'prompt'
104-        PR_GIT_UPDATE=