check_for_upgrade.sh 721 B

1234567891011121314151617181920212223242526272829303132333435
  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. /usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh
  23. # update the zsh file
  24. _update_zsh_update
  25. fi
  26. fi
  27. else
  28. # create the zsh file
  29. _update_zsh_update
  30. fi