Add fetch indicator to bashrc
This commit is contained in:
parent
3e6635e3ba
commit
f68c1505c9
1 changed files with 12 additions and 4 deletions
16
bashrc
16
bashrc
|
@ -37,20 +37,28 @@ git__fetch() {
|
||||||
else
|
else
|
||||||
diff=9999
|
diff=9999
|
||||||
fi
|
fi
|
||||||
if [ $diff -gt $timeout ]; then
|
if [ $diff -gt $timeout ]
|
||||||
|
then run=1
|
||||||
|
else run=0
|
||||||
|
fi
|
||||||
|
if [ $run -gt 0 ]; then
|
||||||
touch $1/.git/FETCH_HEAD
|
touch $1/.git/FETCH_HEAD
|
||||||
nohup git fetch > /dev/null 2>&1 &
|
nohup git fetch > /dev/null 2>&1 &
|
||||||
fi
|
fi
|
||||||
|
echo $run
|
||||||
}
|
}
|
||||||
|
|
||||||
git__prompt () {
|
git__prompt () {
|
||||||
top=$(git rev-parse --show-toplevel 2>/dev/null)
|
top=$(git rev-parse --show-toplevel 2>/dev/null)
|
||||||
if [ -n "$top" ]
|
if [ -n "$top" ]
|
||||||
then
|
then
|
||||||
if [ $BASH_AUTOFETCH ]; then
|
if [ $BASH_AUTOFETCH -gt 0 ]; then
|
||||||
git__fetch $top
|
autofetch=$(git__fetch $top)
|
||||||
|
f=$((2-$autofetch))
|
||||||
|
else
|
||||||
|
f=3
|
||||||
fi
|
fi
|
||||||
echo -ne ' \033[00;33mδ'
|
echo -ne " \033[00;3${f}mδ\033[00;33m"
|
||||||
status=`git status --short 2>/dev/null`
|
status=`git status --short 2>/dev/null`
|
||||||
branch=`git branch | grep -Po '(?<=\* )[[:alnum:]_.-]*'`
|
branch=`git branch | grep -Po '(?<=\* )[[:alnum:]_.-]*'`
|
||||||
modif=`echo "$status" | grep -Po '^\s*M' | wc -l`
|
modif=`echo "$status" | grep -Po '^\s*M' | wc -l`
|
||||||
|
|
Loading…
Reference in a new issue