Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up git dirty #189

Merged
merged 2 commits into from
Nov 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion functions/_pure_prompt_git_dirty.fish
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ function _pure_prompt_git_dirty
set --local git_dirty_symbol
set --local git_dirty_color

set --local is_git_dirty (command git status --porcelain --ignore-submodules 2>/dev/null)
set --local is_git_dirty (
# The first checks for staged changes, the second for unstaged ones.
# We put them in this order because checking staged changes is *fast*.
not command git diff-index --ignore-submodules --cached --quiet HEAD -- >/dev/null 2>&1
or not command git diff --ignore-submodules --no-ext-diff --quiet --exit-code >/dev/null 2>&1
and echo "true"
)
if test -n "$is_git_dirty" # untracked or un-commited files
set git_dirty_symbol "$pure_symbol_git_dirty"
set git_dirty_color "$pure_color_git_dirty"
Expand Down