diff options
author | Marc Cornellà <hello@mcornella.com> | 2021-12-27 00:38:58 +0100 |
---|---|---|
committer | Marc Cornellà <hello@mcornella.com> | 2022-01-03 13:50:52 +0100 |
commit | 43be5ea32150912ae2e85e2cc278c092022ea53f (patch) | |
tree | f9366fe2d37d42f29a3b7e3006ac5f32a6d61a14 | |
parent | 4e777ef9d62f70ec971a3eaca71a23b9f4c93a54 (diff) | |
download | zsh-43be5ea32150912ae2e85e2cc278c092022ea53f.tar.gz zsh-43be5ea32150912ae2e85e2cc278c092022ea53f.tar.bz2 zsh-43be5ea32150912ae2e85e2cc278c092022ea53f.zip |
fix(bureau): quote % in git prompt function and remove global variables
-rw-r--r-- | themes/bureau.zsh-theme | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/themes/bureau.zsh-theme b/themes/bureau.zsh-theme index 3b3bdc80f..7a253a688 100644 --- a/themes/bureau.zsh-theme +++ b/themes/bureau.zsh-theme @@ -17,13 +17,14 @@ ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[yellow]%}●%{$reset_color%}" ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}" bureau_git_branch () { + local ref ref=$(command git symbolic-ref HEAD 2> /dev/null) || \ ref=$(command git rev-parse --short HEAD 2> /dev/null) || return echo "${ref#refs/heads/}" } bureau_git_status() { - _STATUS="" + local _STATUS _INDEX # check status of files _INDEX=$(command git status --porcelain 2> /dev/null) @@ -63,18 +64,22 @@ bureau_git_status() { echo $_STATUS } -bureau_git_prompt () { - local _branch=$(bureau_git_branch) - local _status=$(bureau_git_status) - local _result="" - if [[ "${_branch}x" != "x" ]]; then - _result="$ZSH_THEME_GIT_PROMPT_PREFIX$_branch" - if [[ "${_status}x" != "x" ]]; then - _result="$_result $_status" - fi - _result="$_result$ZSH_THEME_GIT_PROMPT_SUFFIX" +bureau_git_prompt() { + local branch=$(bureau_git_branch) + local status=$(bureau_git_status) + local info + + if [[ -z "${branch}" ]]; then + return + fi + + info="${branch:gs/%/%%}" + + if [[ -n "${status}" ]]; then + info+=" $status" fi - echo $_result + + echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${info}${ZSH_THEME_GIT_PROMPT_SUFFIX}" } |