]> git.rmz.io Git - dotfiles.git/blob - zsh/lib/chpwd.zsh
1763cd54d02f35dbfcd4f174d3aa61361bb5da82
[dotfiles.git] / 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 ((interval = 24 * 60 * 60)) # 1 day
5 local -i time=$(date -u +%s)
6 local -i fetch_time=$(git config custom.fetch-time)
7 if (( $time - $fetch_time > $interval )); then
8 echo "Fetching from repositories..."
9 git fetch
10 git config custom.fetch-time $(date -u +%s)
11 fi
12 fi
13 }
14 chpwd_functions+=(git_auto_fetch)