]>
git.rmz.io Git - dotfiles.git/blob - zsh/lib/chpwd.zsh
1 function git_auto_fetch
{
2 # auto git fetch on intervals
3 if [[ -d .git
]] || git
rev-parse --git-dir 2>/dev
/null
1>&2; then
4 # read interval or store default
6 if ! interval
=$(git config custom.fetch-interval); then
7 ((interval
= 24 * 60 * 60)) # 1 day
8 git config custom.fetch
-interval $interval
11 # Don't fetch if interval is <= 0
12 (( $interval <= 0 )) && return
14 local -i time=$(date -u +%s)
15 local -i fetch_time
=$(git config custom.fetch-time)
16 if (( $time - $fetch_time > $interval )); then
17 echo "Fetching from repositories..."
19 git config custom.fetch
-time $(date -u +%s)
23 chpwd_functions
+=(git_auto_fetch
)