check_for_upgrade.sh 639 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/sh
  2. function _current_epoch() {
  3. echo $(($(date +%s) / 60 / 60 / 24))
  4. }
  5. function _update_zsh_update() {
  6. echo "LAST_EPOCH=$(_current_epoch)" > ~/.zsh-update
  7. }
  8. if [ -f ~/.zsh-update ]
  9. then
  10. . ~/.zsh-update
  11. if [[ -z "$LAST_EPOCH" ]]; then
  12. _update_zsh_update && return 0;
  13. fi
  14. epoch_diff=$(($(_current_epoch) - $LAST_EPOCH))
  15. if [ $epoch_diff -gt 6 ]
  16. then
  17. echo "[Oh My Zsh] Would you like to check for updates?"
  18. echo "Type Y to update oh-my-zsh: \c"
  19. read line
  20. if [ "$line" = Y ] || [ "$line" = y ]
  21. then
  22. /bin/sh $ZSH/tools/upgrade.sh
  23. fi
  24. fi
  25. fi
  26. # update the zsh file
  27. _update_zsh_update