Permalink
Browse files

speed up git dirty check. WAY faster. thanks @sindresorhus. fixes #6

  • Loading branch information...
1 parent 1d6c3be commit 7e8e2ba270e2ac5768489534fa401cd66ee2b83c @paulirish committed Dec 21, 2012
Showing with 2 additions and 4 deletions.
  1. +2 −4 .bash_prompt
View
@@ -3,8 +3,6 @@
default_username='paulirish'
-
-
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then
@@ -38,9 +36,9 @@ else
RESET="\033[m"
fi
-
+# Fastest possible way to check if repo is dirty. a savior for the WebKit repo.
function parse_git_dirty() {
- [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
+ git diff --quiet --ignore-submodules HEAD 2>/dev/null; [ $? -eq 1 ] && echo '*'
}
function parse_git_branch() {

1 comment on commit 7e8e2ba

Just out of curiosity, is this faster/better/preferable to:

GIT_PS1_SHOWDIRTYSTATE=true
_git_ps1

Thanks for sharing your dotfiles, I find them (and your other work) very inspiring.

Please sign in to comment.