028fdf2e9948fa720599a63cd36124eff95cb6fc

Author
slavaGanzin <slava.ganzin@gmail.com>
Committer
slavaGanzin <slava.ganzin@gmail.com>
Date

Message

add coloring

Diff

 1diff --git a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh
 2index 0bcefa9312fbcc0d20737ccb53a1b2533e5ae54f..949709e4c065efd560dbeec68cf8141a6c39a322 100644
 3--- a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh
 4+++ b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh
 5@@ -1,15 +1,20 @@
 6-function git_fetch_on_chpwd {
 7-  ([[ -d .git ]] && [[ ! -f ".git/NO_AUTO_FETCH" ]] && git fetch --all &>! .git/FETCH_LOG &)
 8+function git-fetch-on-chpwd {
 9+  (`git rev-parse --is-inside-work-tree 2>/dev/null` &&
10+  dir=`git rev-parse --git-dir` &&
11+  [[ ! -f $dir/NO_AUTO_FETCH ]] &&
12+  git fetch --all &>! $dir/FETCH_LOG &)
13 }
14 
15 function git-auto-fetch {
16-  [[ ! -d .git ]] && return
17-  if [[ -f ".git/NO_AUTO_FETCH" ]]; then
18-    rm ".git/NO_AUTO_FETCH" && echo "${fg_bold[red]}disabled${reset_color}"
19-  else
20-    touch ".git/NO_AUTO_FETCH" && echo "${fg_bold[green]}enabled${reset_color}"
21-  fi
22+  `git rev-parse --is-inside-work-tree 2>/dev/null` || return
23+  guard="`git rev-parse --git-dir`/NO_AUTO_FETCH"
24+
25+  (rm $guard 2>/dev/null &&
26+    echo "${fg_bold[green]}enabled${reset_color}") ||
27+  (touch $guard &&
28+    echo "${fg_bold[red]}disabled${reset_color}")
29 }
30-chpwd_functions+=(git_fetch_on_chpwd)
31-git_fetch_on_chpwd
32-unset git_fetch_on_chpwd
33+
34+chpwd_functions+=(git-fetch-on-chpwd)
35+git-fetch-on-chpwd
36+unset git-fetch-on-chpwd