From 0df8692fa812b5cefd12543cf6a6a49c135d4157 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sun, 30 Jun 2019 23:17:36 -0400 Subject: [PATCH] Fix error in bare git repositories --- prompt_fred_setup | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/prompt_fred_setup b/prompt_fred_setup index 6bcaa62..03cd5d0 100644 --- a/prompt_fred_setup +++ b/prompt_fred_setup @@ -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