From 4891bf41fdd05408d55af7dd5b7927fd7068c2f3 Mon Sep 17 00:00:00 2001 From: Eli Block <3347571+eliblock@users.noreply.github.com> Date: Thu, 14 May 2020 17:37:47 -0700 Subject: [PATCH 1/2] fix: respect parse_git_dirty clean result $dirty will be empty if parse_git_dirty returns a clean result - which may happen because the working directory is clean or because a configuration has been set (e.g., oh-my-zsh.hide-dirty) which disables the check. In either event, we should respect the former check and avoid querying for a dirty working directory a second time. --- themes/agnoster.zsh-theme | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 8c700d06a..2b1ea6d11 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -129,7 +129,11 @@ prompt_git() { zstyle ':vcs_info:*' enable git zstyle ':vcs_info:*' get-revision true - zstyle ':vcs_info:*' check-for-changes true + if [[ -z $dirty ]]; then + zstyle ':vcs_info:*' check-for-staged-changes true + else + zstyle ':vcs_info:*' check-for-changes true + fi zstyle ':vcs_info:*' stagedstr '✚' zstyle ':vcs_info:*' unstagedstr '●' zstyle ':vcs_info:*' formats ' %u%c' From 05cfadc5d8f0503d393367c6cdbbe18ce3db3720 Mon Sep 17 00:00:00 2001 From: Eli Block <3347571+eliblock@users.noreply.github.com> Date: Thu, 14 May 2020 17:40:16 -0700 Subject: [PATCH 2/2] feat: plain color branch name when hide-dirty set If hide-dirty is set, parse_git_dirty will not check the directory's status. Rather than coloring the git-status portion of the prompt green (which typically indicates a clean working directory) we color this portion of the prompt white to reflect the lack of information. --- themes/agnoster.zsh-theme | 2 ++ 1 file changed, 2 insertions(+) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 2b1ea6d11..4996f04f3 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -112,6 +112,8 @@ prompt_git() { ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)" if [[ -n $dirty ]]; then prompt_segment yellow black + elif [[ "$(git config --get oh-my-zsh.hide-dirty 2>/dev/null)" = 1 ]]; then + prompt_segment white black else prompt_segment green $CURRENT_FG fi