Created
March 23, 2011 14:29
-
-
Save bps/883177 to your computer and use it in GitHub Desktop.
Sometimes __git_ps1 takes too long. This disables it when we ^C.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# via https://gist.github.com/623371 | |
if [[ $(declare -f __git_ps1) ]]; then | |
export GIT_PS1_SHOWDIRTYSTATE=1 | |
export GIT_PS1_SHOWSTASHSTATE=1 | |
export GIT_PS1_SHOWUNTRACKEDFILES=1 | |
git_ps1_disable () | |
{ | |
_skip_git_ps1=1 | |
} | |
git_ps1_enable () | |
{ | |
unset _skip_git_ps1 | |
} | |
_update_prompt () | |
{ | |
local this_git_status="" | |
if [ -z "${_skip_git_ps1}" ]; then | |
this_git_status=$(__git_ps1 "(%s)") | |
case $? in | |
0 ) : ;; | |
130 ) git_ps1_disable;; # If we break that last command because it's too slow, stop trying it | |
esac | |
fi | |
export PS1=": \u@\h \w${this_git_status}; " | |
} | |
export PROMPT_COMMAND=_update_prompt | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment