From 7dfa56461e8b491f18ae3db9579fd7a25c9120ed Mon Sep 17 00:00:00 2001 From: Edward Dorrington Date: Fri, 11 Apr 2014 11:54:19 -0700 Subject: [PATCH] Added code to only check for updates every 24 hours --- .gitignore | 1 + .zshrc | 29 +++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f720807..fbc2fa4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ zshrc +.lastcheck diff --git a/.zshrc b/.zshrc index c5d1663..ff55d5c 100644 --- a/.zshrc +++ b/.zshrc @@ -1,9 +1,34 @@ # Path to your oh-my-zsh configuration. ZSH=$HOME/.oh-my-zsh -echo "Updating config" +# Update config once every 24 hours cd $HOME/.zcustom -git pull +case "`uname`" in + Linux) + STATARGS="-c %Z" + ;; + Darwin) + STATARGS="-f %m" + ;; + *) + echo "Error! Unknown system `uname`" + exit 1 + ;; +esac +if [ -f .lastcheck ]; then + # if it hasn't been touched in the last 24 hours + NOW=`date +%s` + LAST=`stat $STATARGS .lastcheck` + if [ $(($NOW - $LAST)) -gt 86400 ]; then + echo "Updating config" + git pull + fi +else + # Doesn't exist + touch .lastcheck + echo "Updating config" + git pull +fi cd # Aliases