From c8576d59ca7da85e66b9477b737f881448d50cd3 Mon Sep 17 00:00:00 2001 From: Andrea Mistrali Date: Thu, 16 Dec 2021 09:52:45 +0100 Subject: [PATCH] Autoload zsh-hooks and cleanups in gitfetch --- zsh.d/50-functions.zsh | 3 +++ zsh.d/zshfunctions/gitfetch | 8 +++----- 2 files changed, 6 insertions(+), 5 deletions(-) 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