--- /dev/null
+function git_auto_fetch {
+ # auto git fetch on intervals
+ if [[ -d .git ]] || git rev-parse --git-dir 2>/dev/null 1>&2; then
+ ((interval = 24 * 60 * 60)) # 1 day
+ local -i time=$(date -u +%s)
+ local -i fetch_time=$(git config custom.fetch-time)
+ if (( $time - $fetch_time > $interval )); then
+ echo "Fetching from repositories..."
+ git fetch
+ git config custom.fetch-time $(date -u +%s)
+ fi
+ fi
+}
+chpwd_functions+=(git_auto_fetch)