ohmyzsh/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh

16 lines
473 B
Bash
Raw Normal View History

2016-09-29 18:05:49 +02:00
function git_fetch_on_chpwd {
2016-10-04 20:26:19 +02:00
([[ -d .git ]] && [[ ! -f ".git/NO_AUTO_FETCH" ]] && git fetch --all &>! .git/FETCH_LOG &)
}
function git-auto-fetch {
[[ ! -d .git ]] && return
if [[ -f ".git/NO_AUTO_FETCH" ]]; then
2016-10-06 15:55:21 +02:00
rm ".git/NO_AUTO_FETCH" && echo "${fg_bold[red]}disabled${reset_color}"
2016-10-04 20:26:19 +02:00
else
2016-10-06 15:55:21 +02:00
touch ".git/NO_AUTO_FETCH" && echo "${fg_bold[green]}enabled${reset_color}"
2016-10-04 20:26:19 +02:00
fi
2016-09-29 18:05:49 +02:00
}
2016-09-29 21:14:04 +02:00
chpwd_functions+=(git_fetch_on_chpwd)
git_fetch_on_chpwd
2016-10-04 20:26:19 +02:00
unset git_fetch_on_chpwd