diff --git a/zsh.d/50-functions.zsh b/zsh.d/50-functions.zsh index e8ed3e6..fabb72c 100644 --- a/zsh.d/50-functions.zsh +++ b/zsh.d/50-functions.zsh @@ -12,3 +12,6 @@ zmodload zsh/datetime # Autoload all functions in zshfunctions # autoload -U $LIBRARY/zshfunctions/*(.:t) + +# Add zsh-hook function +autoload -Uz add-zsh-hook diff --git a/zsh.d/zshfunctions/gitfetch b/zsh.d/zshfunctions/gitfetch index b11bcf7..e4fc4a1 100644 --- a/zsh.d/zshfunctions/gitfetch +++ b/zsh.d/zshfunctions/gitfetch @@ -1,14 +1,12 @@ -zmodload -F zsh/stat b:zstat -zmodload zsh/datetime local _gitdir local last_fetch local diff cd $1 -_gitdir=$(git rev-parse --git-dir 2> /dev/null) || return 0 -last_fetch=$(zstat +mtime $_gitdir/FETCH_HEAD 2> /dev/null || echo 0) -let "diff = $(strftime %s)- $last_fetch" +gitdir=$(git rev-parse --git-dir 2> /dev/null) || return 0 +last_fetch=$(zstat +mtime $gitdir/FETCH_HEAD 2> /dev/null || echo 0) +let "diff = $(strftime %s) - $last_fetch" [ $diff -gt ${GIT_FETCH_INTERVAL:-30} ] && git fetch --all -p return 0