X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/e13a60251b6e72001791dd8cef0e60f99d406e28..e905a477887c2b36114f465dd7e82b032903bb3c:/zsh/lib/chpwd.zsh diff --git a/zsh/lib/chpwd.zsh b/zsh/lib/chpwd.zsh new file mode 100644 index 0000000..1763cd5 --- /dev/null +++ b/zsh/lib/chpwd.zsh @@ -0,0 +1,14 @@ +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)