From dc640860ac8d375fbb9443b74c7f423ec27dace0 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 1 May 2013 17:05:40 +0200 Subject: [PATCH] Improve logic for checking if inside a git repo --- prompt.zsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/prompt.zsh b/prompt.zsh index 4107c95..dcb4356 100644 --- a/prompt.zsh +++ b/prompt.zsh @@ -34,8 +34,10 @@ zstyle ':vcs_info:git*' actionformats ' %b|%a' # Fastest possible way to check if repo is dirty git_dirty() { - [ -d .git ] || return - command git diff --quiet --ignore-submodules HEAD 2>/dev/null; [ $? -eq 1 ] && echo '*' + # check if we're in a git repo + command git rev-parse --is-inside-work-tree &>/dev/null || return + # check if it's dirty + command git diff --quiet --ignore-submodules HEAD &>/dev/null; [ $? -eq 1 ] && echo '*' } # Displays the exec time of the last command if set threshold was exceeded