git-auto-fetch.plugin.zsh 574 B

1234567891011121314151617181920
  1. function git-fetch-on-chpwd {
  2. (`git rev-parse --is-inside-work-tree 2>/dev/null` &&
  3. dir=`git rev-parse --git-dir` &&
  4. [[ ! -f $dir/NO_AUTO_FETCH ]] &&
  5. git fetch --all &>! $dir/FETCH_LOG &)
  6. }
  7. function git-auto-fetch {
  8. `git rev-parse --is-inside-work-tree 2>/dev/null` || return
  9. guard="`git rev-parse --git-dir`/NO_AUTO_FETCH"
  10. (rm $guard 2>/dev/null &&
  11. echo "${fg_bold[green]}enabled${reset_color}") ||
  12. (touch $guard &&
  13. echo "${fg_bold[red]}disabled${reset_color}")
  14. }
  15. chpwd_functions+=(git-fetch-on-chpwd)
  16. git-fetch-on-chpwd
  17. unset git-fetch-on-chpwd