Fix error in bare git repositories

This commit is contained in:
Adam Goldsmith 2019-06-30 23:17:36 -04:00
parent 98a2cbebe4
commit 0df8692fa8
1 changed files with 7 additions and 5 deletions

View File

@ -25,10 +25,15 @@ prompt_context() {
print "%B%(!.%F{red}.%F{green})%n@${host}"
}
prompt_git_dirty () {
[[ "$(git rev-parse --is-inside-work-tree)" == "true" && \
-n "$(git status --porcelain --ignore-submodules)" ]]
}
rprompt_git() {
ref=${vcs_info_msg_0_}
if [[ -n ${ref} ]]; then
if test -n "$(git status --porcelain --ignore-submodules)"; then
if prompt_git_dirty; then
print '%F{yellow}'$GIT_DIRTY_CHAR'%f'
fi
fi
@ -37,12 +42,9 @@ rprompt_git() {
# Git: branch/detached head, dirty status
prompt_git() {
local color ref
is_dirty() {
test -n "$(git status --porcelain --ignore-submodules)"
}
ref=${vcs_info_msg_0_}
if [[ -n ${ref} ]]; then
if is_dirty; then
if prompt_git_dirty; then
color=yellow
else
color=green