43be5ea32150912ae2e85e2cc278c092022ea53f
- Author
- Marc Cornellà <hello@mcornella.com>
- Committer
- Marc Cornellà <hello@mcornella.com>
- Date
Message
fix(bureau): quote % in git prompt function and remove global variables
Diff
1diff --git a/themes/bureau.zsh-theme b/themes/bureau.zsh-theme
2index 3b3bdc80f3183da358a6ef1720bc0ed4f8f7dda5..7a253a688f50aa045f394ba76759eae33fa6da55 100644
3--- a/themes/bureau.zsh-theme
4+++ b/themes/bureau.zsh-theme
5@@ -17,13 +17,14 @@ ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[yellow]%}●%{$reset_color%}"
6 ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}"
7
8 bureau_git_branch () {
9+ local ref
10 ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
11 ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
12 echo "${ref#refs/heads/}"
13 }
14
15 bureau_git_status() {
16- _STATUS=""
17+ local _STATUS _INDEX
18
19 # check status of files
20 _INDEX=$(command git status --porcelain 2> /dev/null)
21@@ -63,18 +64,22 @@ bureau_git_status() {
22 echo $_STATUS
23 }
24
25-bureau_git_prompt () {
26- local _branch=$(bureau_git_branch)
27- local _status=$(bureau_git_status)
28- local _result=""
29- if [[ "${_branch}x" != "x" ]]; then
30- _result="$ZSH_THEME_GIT_PROMPT_PREFIX$_branch"
31- if [[ "${_status}x" != "x" ]]; then
32- _result="$_result $_status"
33- fi
34- _result="$_result$ZSH_THEME_GIT_PROMPT_SUFFIX"
35+bureau_git_prompt() {
36+ local branch=$(bureau_git_branch)
37+ local status=$(bureau_git_status)
38+ local info
39+
40+ if [[ -z "${branch}" ]]; then
41+ return
42+ fi
43+
44+ info="${branch:gs/%/%%}"
45+
46+ if [[ -n "${status}" ]]; then
47+ info+=" $status"
48 fi
49- echo $_result
50+
51+ echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${info}${ZSH_THEME_GIT_PROMPT_SUFFIX}"
52 }
53
54