Added code to only check for updates every 24 hours

This commit is contained in:
2014-04-11 11:54:19 -07:00
parent 9e18b928d8
commit 7dfa56461e
2 changed files with 28 additions and 2 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
zshrc
.lastcheck

29
.zshrc
View File

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