Autoload zsh-hooks and cleanups in gitfetch

This commit is contained in:
Andrea Mistrali 2021-12-16 09:52:45 +01:00
parent ca8a24d28e
commit c8576d59ca
No known key found for this signature in database
GPG Key ID: 6FB0A77F6D5DA9B2
2 changed files with 6 additions and 5 deletions

View File

@ -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

View File

@ -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