Add timeouts to git_prompt
This commit is contained in:
parent
27e6bec137
commit
8466195475
1 changed files with 14 additions and 13 deletions
27
shell/prompt
27
shell/prompt
|
@ -53,7 +53,7 @@ git__fetch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
gitprompt () {
|
gitprompt () {
|
||||||
top=$(git rev-parse --show-toplevel 2>/dev/null)
|
top=$(timeout 1 git rev-parse --show-toplevel 2>/dev/null)
|
||||||
if [ -n "$top" ]
|
if [ -n "$top" ]
|
||||||
then
|
then
|
||||||
if [ "$BASH_AUTOFETCH" -gt 0 ]; then
|
if [ "$BASH_AUTOFETCH" -gt 0 ]; then
|
||||||
|
@ -62,13 +62,13 @@ gitprompt () {
|
||||||
else
|
else
|
||||||
f=3
|
f=3
|
||||||
fi
|
fi
|
||||||
status=$(git status --short 2>/dev/null)
|
git_status=$(timeout 1 git status --short 2>/dev/null)
|
||||||
branch=$(git branch | grep -Po '(?<=\* )[[:alnum:]_.-]*')
|
git_branch=$(git branch | grep -Po '(?<=\* )[[:alnum:]_.-]*')
|
||||||
modif=$(echo "$status" | grep -Po '^\s*M' | wc -l)
|
modif=$(echo "$git_status" | grep -Po '^\s*M' | wc -l)
|
||||||
untracked=$(echo "$status" | grep -Po '^\?\?' | wc -l)
|
untracked=$(echo "$git_status" | grep -Po '^\?\?' | wc -l)
|
||||||
added=$(echo "$status" | grep -Po '^\s*[A]' | wc -l)
|
added=$(echo "$git_status" | grep -Po '^\s*[A]' | wc -l)
|
||||||
deleted=$(echo "$status" | grep -Po '^\s*[D]' | wc -l)
|
deleted=$(echo "$git_status" | grep -Po '^\s*[D]' | wc -l)
|
||||||
renamed=$(echo "$status" | grep -Eo '^\s*R' | wc -l)
|
renamed=$(echo "$git_status" | grep -Eo '^\s*R' | wc -l)
|
||||||
stat=$(git branch -vv | grep -P '^\*' | grep -Po '\[.*\]')
|
stat=$(git branch -vv | grep -P '^\*' | grep -Po '\[.*\]')
|
||||||
ahead=$(echo $stat | grep -Po '(?<=ahead )\d*')
|
ahead=$(echo $stat | grep -Po '(?<=ahead )\d*')
|
||||||
behind=$(echo $stat | grep -Po '(?<=behind )\d*')
|
behind=$(echo $stat | grep -Po '(?<=behind )\d*')
|
||||||
|
@ -88,21 +88,21 @@ gitprompt () {
|
||||||
head=$(git rev-parse --short HEAD 2>&1)
|
head=$(git rev-parse --short HEAD 2>&1)
|
||||||
if [ "$(echo "$head" | grep '^fatal')" ]
|
if [ "$(echo "$head" | grep '^fatal')" ]
|
||||||
then
|
then
|
||||||
branch='{no commits}'
|
git_branch='{no commits}'
|
||||||
else
|
else
|
||||||
branch='#'"$head"
|
git_branch='#'"$head"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$branch" = 'master' ]
|
if [ "$git_branch" = 'master' ]
|
||||||
then
|
then
|
||||||
/bin/echo -ne "$blue"
|
/bin/echo -ne "$blue"
|
||||||
elif [ $(echo "$branch" | grep '^#' ) ]
|
elif [ $(echo "$git_branch" | grep '^#' ) ]
|
||||||
then
|
then
|
||||||
/bin/echo -ne "$red"
|
/bin/echo -ne "$red"
|
||||||
else
|
else
|
||||||
/bin/echo -ne "$yellow"
|
/bin/echo -ne "$yellow"
|
||||||
fi
|
fi
|
||||||
/bin/echo -ne "$branch\033[00;36m"
|
/bin/echo -ne "$git_branch\033[00;36m"
|
||||||
|
|
||||||
# SYNC
|
# SYNC
|
||||||
if [ -z "$ahead" ] && [ -z "$behind" ]
|
if [ -z "$ahead" ] && [ -z "$behind" ]
|
||||||
|
@ -141,6 +141,7 @@ gitprompt () {
|
||||||
then
|
then
|
||||||
/bin/echo -ne " ${yellow}+$untracked"
|
/bin/echo -ne " ${yellow}+$untracked"
|
||||||
fi
|
fi
|
||||||
|
/bin/echo -ne "\033[00m"
|
||||||
else
|
else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue