8e973d42bd3bc5028d88ce731113b03ac8a5590c
- Author
- Marc Cornellà <hello@mcornella.com>
- Committer
- Marc Cornellà <hello@mcornella.com>
- Date
Message
fix(bureau): fix `status` variable name causing error (#10561)
Also cleaned up the code a bit
Fixes #10561
Diff
1diff --git a/themes/bureau.zsh-theme b/themes/bureau.zsh-theme
2index 7a253a688f50aa045f394ba76759eae33fa6da55..50058e213ef7cdfc20ff9744278390e67e7c02b4 100644
3--- a/themes/bureau.zsh-theme
4+++ b/themes/bureau.zsh-theme
5@@ -24,59 +24,58 @@ bureau_git_branch () {
6 }
7
8 bureau_git_status() {
9- local _STATUS _INDEX
10+ local result gitstatus
11
12 # check status of files
13- _INDEX=$(command git status --porcelain 2> /dev/null)
14- if [[ -n "$_INDEX" ]]; then
15- if $(echo "$_INDEX" | command grep -q '^[AMRD]. '); then
16- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
17+ gitstatus=$(command git status --porcelain -b 2> /dev/null)
18+ if [[ -n "$gitstatus" ]]; then
19+ if $(echo "$gitstatus" | command grep -q '^[AMRD]. '); then
20+ result+="$ZSH_THEME_GIT_PROMPT_STAGED"
21 fi
22- if $(echo "$_INDEX" | command grep -q '^.[MTD] '); then
23- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
24+ if $(echo "$gitstatus" | command grep -q '^.[MTD] '); then
25+ result+="$ZSH_THEME_GIT_PROMPT_UNSTAGED"
26 fi
27- if $(echo "$_INDEX" | command grep -q -E '^\?\? '); then
28- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED"
29+ if $(echo "$gitstatus" | command grep -q -E '^\?\? '); then
30+ result+="$ZSH_THEME_GIT_PROMPT_UNTRACKED"
31 fi
32- if $(echo "$_INDEX" | command grep -q '^UU '); then
33- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
34+ if $(echo "$gitstatus" | command grep -q '^UU '); then
35+ result+="$ZSH_THEME_GIT_PROMPT_UNMERGED"
36 fi
37 else
38- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_CLEAN"
39+ result+="$ZSH_THEME_GIT_PROMPT_CLEAN"
40 fi
41
42 # check status of local repository
43- _INDEX=$(command git status --porcelain -b 2> /dev/null)
44- if $(echo "$_INDEX" | command grep -q '^## .*ahead'); then
45- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_AHEAD"
46+ if $(echo "$gitstatus" | command grep -q '^## .*ahead'); then
47+ result+="$ZSH_THEME_GIT_PROMPT_AHEAD"
48 fi
49- if $(echo "$_INDEX" | command grep -q '^## .*behind'); then
50- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_BEHIND"
51+ if $(echo "$gitstatus" | command grep -q '^## .*behind'); then
52+ result+="$ZSH_THEME_GIT_PROMPT_BEHIND"
53 fi
54- if $(echo "$_INDEX" | command grep -q '^## .*diverged'); then
55- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_DIVERGED"
56+ if $(echo "$gitstatus" | command grep -q '^## .*diverged'); then
57+ result+="$ZSH_THEME_GIT_PROMPT_DIVERGED"
58 fi
59
60 if $(command git rev-parse --verify refs/stash &> /dev/null); then
61- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STASHED"
62+ result+="$ZSH_THEME_GIT_PROMPT_STASHED"
63 fi
64
65- echo $_STATUS
66+ echo $result
67 }
68
69 bureau_git_prompt() {
70- local branch=$(bureau_git_branch)
71- local status=$(bureau_git_status)
72+ local gitbranch=$(bureau_git_branch)
73+ local gitstatus=$(bureau_git_status)
74 local info
75
76- if [[ -z "${branch}" ]]; then
77+ if [[ -z "$gitbranch" ]]; then
78 return
79 fi
80
81- info="${branch:gs/%/%%}"
82+ info="${gitbranch:gs/%/%%}"
83
84- if [[ -n "${status}" ]]; then
85- info+=" $status"
86+ if [[ -n "$gitstatus" ]]; then
87+ info+=" $gitstatus"
88 fi
89
90 echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${info}${ZSH_THEME_GIT_PROMPT_SUFFIX}"