From b8c03d4e256c4c9cdb391a4ffe245c80e7fd7907 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Tue, 5 Feb 2019 22:32:38 +0100 Subject: [PATCH] git: Return prompt fragments only inside of a Git repository --- plugins/git/git.zshrc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/git/git.zshrc b/plugins/git/git.zshrc index 55c395f..2b039c2 100644 --- a/plugins/git/git.zshrc +++ b/plugins/git/git.zshrc @@ -38,15 +38,18 @@ git_prompt_behind() { git_prompt_info() { local ref=$(git symbolic-ref HEAD 2>/dev/null) || return 1 + [[ -n "$ref" ]] || return 1 echo "${ref#refs/heads/}" } git_prompt_status() { + local ref=$(git symbolic-ref HEAD 2>/dev/null) || return 1 + [[ -n "$ref" ]] || return 1 echo "$(git_parse_dirty)$(git_prompt_ahead)$(git_prompt_behind)" } git_prompt() { local prompt=$(git_prompt_info) - [[ -n "$prompt" ]] || return 0 + [[ -n "$prompt" ]] || return 1 echo "$prompt$(git_prompt_status)" return 0 } -- 2.39.2