check_for_upgrade.sh 705 B

12345678910111213141516171819202122232425262728
  1. #!/bin/sh
  2. current_epoch=$(($(date +%s) / 60 / 60 / 24))
  3. if [ -f ~/.zsh-update ]
  4. then
  5. . ~/.zsh-update
  6. epoch_diff=$(($current_epoch - $LAST_EPOCH))
  7. if [ $epoch_diff -gt 6 ]
  8. then
  9. echo "[Oh My Zsh] Would you like to check for updates?"
  10. echo "Type Y to update oh-my-zsh: \c"
  11. read line
  12. if [ "$line" = Y ] || [ "$line" = y ]
  13. then
  14. /bin/sh $ZSH/tools/upgrade.sh
  15. fi
  16. # Set the last epoch to the current so that we don't ask for another week
  17. echo "LAST_EPOCH=${current_epoch}" > ~/.zsh-update
  18. fi
  19. else
  20. # TODO: refactor this so remove duplicates
  21. # Create the ~/.zsh-update file with the current epoch info
  22. echo "LAST_EPOCH=${current_epoch}" > ~/.zsh-update
  23. fi