From 7a6a5c5ed229b25e5f318122d4c422179541f8ac Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Tue, 7 Jan 2020 10:51:55 +0100 Subject: [PATCH] Improve bash autofetch feature Added BASH_AUTOFETCH_TIMEOUT option and actually sent fetching to the background. --- bashrc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bashrc b/bashrc index c3a85c7..ea4620e 100644 --- a/bashrc +++ b/bashrc @@ -27,14 +27,19 @@ stty -ixon set -o vi git__fetch() { + if [ -n "$BASH_AUTOFETCH_TIMEOUT" ]; then + timeout=$BASH_AUTOFETCH_TIMEOUT + else + timeout=60 + fi if [ -f $1/.git/FETCH_HEAD ]; then diff=$(($(date +%s) - $(stat -c %Y $1/.git/FETCH_HEAD))) else diff=9999 fi - if [ $diff -gt 60 ]; then + if [ $diff -gt $timeout ]; then touch $1/.git/FETCH_HEAD - nohup git fetch > /dev/null 2>&1 + nohup git fetch > /dev/null 2>&1 & fi }