From 99fc183e3d1c30b644a996839c05c70c8ea54980 Mon Sep 17 00:00:00 2001 From: Eder Ruiz Maria Date: Sat, 13 Oct 2012 21:45:01 -0400 Subject: [PATCH] fix: when in git directory and not in a branch, show (no branch) --- lib/git.zsh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index b2ff9726c..c6ac372b6 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -1,7 +1,10 @@ # get the name of the branch we are on function git_prompt_info() { - ref=$(git symbolic-ref HEAD 2> /dev/null) || return - echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" + if ! git status &> /dev/null; then + return + fi + branch=$(git branch | grep ^\* | cut -d" " -f2-) + echo "$ZSH_THEME_GIT_PROMPT_PREFIX${branch}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" }