upgrade.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # Use colors, but only if connected to a terminal, and that terminal
  2. # supports them.
  3. if [ -t 1 ]; then
  4. RB_RED=$(printf '\033[38;5;196m')
  5. RB_ORANGE=$(printf '\033[38;5;202m')
  6. RB_YELLOW=$(printf '\033[38;5;226m')
  7. RB_GREEN=$(printf '\033[38;5;082m')
  8. RB_BLUE=$(printf '\033[38;5;021m')
  9. RB_INDIGO=$(printf '\033[38;5;093m')
  10. RB_VIOLET=$(printf '\033[38;5;163m')
  11. RED=$(printf '\033[31m')
  12. GREEN=$(printf '\033[32m')
  13. YELLOW=$(printf '\033[33m')
  14. BLUE=$(printf '\033[34m')
  15. BOLD=$(printf '\033[1m')
  16. RESET=$(printf '\033[m')
  17. else
  18. RB_RED=""
  19. RB_ORANGE=""
  20. RB_YELLOW=""
  21. RB_GREEN=""
  22. RB_BLUE=""
  23. RB_INDIGO=""
  24. RB_VIOLET=""
  25. RED=""
  26. GREEN=""
  27. YELLOW=""
  28. BLUE=""
  29. BOLD=""
  30. RESET=""
  31. fi
  32. cd "$ZSH"
  33. # Set git-config values known to fix git errors
  34. # Line endings (#4069)
  35. git config core.eol lf
  36. git config core.autocrlf false
  37. # zeroPaddedFilemode fsck errors (#4963)
  38. git config fsck.zeroPaddedFilemode ignore
  39. git config fetch.fsck.zeroPaddedFilemode ignore
  40. git config receive.fsck.zeroPaddedFilemode ignore
  41. # autostash on rebase (#7172)
  42. resetAutoStash=$(git config --bool rebase.autoStash 2>&1)
  43. git config rebase.autoStash true
  44. # Update upstream remote to ohmyzsh org
  45. remote=$(git remote -v | awk '/https:\/\/github\.com\/robbyrussell\/oh-my-zsh\.git/{ print $1; exit }')
  46. if [ -n "$remote" ]; then
  47. git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git"
  48. fi
  49. printf "${BLUE}%s${RESET}\n" "Updating Oh My Zsh"
  50. if git pull --rebase --stat origin master
  51. then
  52. printf '%s %s__ %s %s %s %s %s__ %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
  53. printf '%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
  54. printf '%s / __ \%s/ __ \ %s / __ `__ \%s/ / / / %s /_ / %s/ ___/%s __ \ %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
  55. printf '%s/ /_/ /%s / / / %s / / / / / /%s /_/ / %s / /_%s(__ )%s / / / %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
  56. printf '%s\____/%s_/ /_/ %s /_/ /_/ /_/%s\__, / %s /___/%s____/%s_/ /_/ %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
  57. printf '%s %s %s %s /____/ %s %s %s %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
  58. printf "${BLUE}%s\n" "Hooray! Oh My Zsh has been updated and/or is at the current version."
  59. printf "${BLUE}${BOLD}%s${RESET}\n" "To keep up on the latest news and updates, follow us on twitter: https://twitter.com/ohmyzsh"
  60. printf "${BLUE}${BOLD}%s${RESET}\n" "Get your Oh My Zsh swag at: https://shop.planetargon.com/collections/oh-my-zsh"
  61. else
  62. printf "${RED}%s${RESET}\n" 'There was an error updating. Try again later?'
  63. fi
  64. # Unset git-config values set just for the upgrade
  65. case "$resetAutoStash" in
  66. "") git config --unset rebase.autoStash ;;
  67. *) git config rebase.autoStash "$resetAutoStash" ;;
  68. esac