upgrade.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Use colors, but only if connected to a terminal, and that terminal
  2. # supports them.
  3. if which tput >/dev/null 2>&1; then
  4. ncolors=$(tput colors)
  5. fi
  6. if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
  7. RED="$(tput setaf 1)"
  8. GREEN="$(tput setaf 2)"
  9. YELLOW="$(tput setaf 3)"
  10. BLUE="$(tput setaf 4)"
  11. BOLD="$(tput bold)"
  12. NORMAL="$(tput sgr0)"
  13. else
  14. RED=""
  15. GREEN=""
  16. YELLOW=""
  17. BLUE=""
  18. BOLD=""
  19. NORMAL=""
  20. fi
  21. cd "$ZSH"
  22. # Set git-config values known to fix git errors
  23. # Line endings (#4069)
  24. git config core.eol lf
  25. git config core.autocrlf false
  26. # zeroPaddedFilemode fsck errors (#4963)
  27. git config fsck.zeroPaddedFilemode ignore
  28. git config fetch.fsck.zeroPaddedFilemode ignore
  29. git config receive.fsck.zeroPaddedFilemode ignore
  30. # Update upstream remote to ohmyzsh org
  31. remote=$(git remote -v | awk '/https:\/\/github\.com\/robbyrussell\/oh-my-zsh\.git/{ print $1; exit }')
  32. if [ -n "$remote" ]; then
  33. git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git"
  34. fi
  35. printf "${BLUE}%s${NORMAL}\n" "Updating Oh My Zsh"
  36. if git -c rebase.autoStash=true pull --rebase --stat origin master
  37. then
  38. printf '%s' "$GREEN"
  39. printf '%s\n' ' __ __ '
  40. printf '%s\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
  41. printf '%s\n' ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
  42. printf '%s\n' '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '
  43. printf '%s\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
  44. printf '%s\n' ' /____/ '
  45. printf "${BLUE}%s\n" "Hooray! Oh My Zsh has been updated and/or is at the current version."
  46. printf "${BLUE}${BOLD}%s${NORMAL}\n" "To keep up on the latest news and updates, follow us on twitter: https://twitter.com/ohmyzsh"
  47. printf "${BLUE}${BOLD}%s${NORMAL}\n" "Get your Oh My Zsh swag at: https://shop.planetargon.com/collections/oh-my-zsh"
  48. else
  49. printf "${RED}%s${NORMAL}\n" 'There was an error updating. Try again later?'
  50. fi