mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-12 21:39:48 +01:00
fix(bureau): quote % in git prompt function and remove global variables
This commit is contained in:
parent
4e777ef9d6
commit
43be5ea321
1 changed files with 17 additions and 12 deletions
|
@ -17,13 +17,14 @@ ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[yellow]%}●%{$reset_color%}"
|
||||||
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}"
|
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}"
|
||||||
|
|
||||||
bureau_git_branch () {
|
bureau_git_branch () {
|
||||||
|
local ref
|
||||||
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
|
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
|
||||||
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
|
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
|
||||||
echo "${ref#refs/heads/}"
|
echo "${ref#refs/heads/}"
|
||||||
}
|
}
|
||||||
|
|
||||||
bureau_git_status() {
|
bureau_git_status() {
|
||||||
_STATUS=""
|
local _STATUS _INDEX
|
||||||
|
|
||||||
# check status of files
|
# check status of files
|
||||||
_INDEX=$(command git status --porcelain 2> /dev/null)
|
_INDEX=$(command git status --porcelain 2> /dev/null)
|
||||||
|
@ -63,18 +64,22 @@ bureau_git_status() {
|
||||||
echo $_STATUS
|
echo $_STATUS
|
||||||
}
|
}
|
||||||
|
|
||||||
bureau_git_prompt () {
|
bureau_git_prompt() {
|
||||||
local _branch=$(bureau_git_branch)
|
local branch=$(bureau_git_branch)
|
||||||
local _status=$(bureau_git_status)
|
local status=$(bureau_git_status)
|
||||||
local _result=""
|
local info
|
||||||
if [[ "${_branch}x" != "x" ]]; then
|
|
||||||
_result="$ZSH_THEME_GIT_PROMPT_PREFIX$_branch"
|
if [[ -z "${branch}" ]]; then
|
||||||
if [[ "${_status}x" != "x" ]]; then
|
return
|
||||||
_result="$_result $_status"
|
|
||||||
fi
|
|
||||||
_result="$_result$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
|
||||||
fi
|
fi
|
||||||
echo $_result
|
|
||||||
|
info="${branch:gs/%/%%}"
|
||||||
|
|
||||||
|
if [[ -n "${status}" ]]; then
|
||||||
|
info+=" $status"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${info}${ZSH_THEME_GIT_PROMPT_SUFFIX}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue