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