From 18c2b481835128d15cc8378cd63f17a905691d7b Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Fri, 6 May 2011 18:31:09 -0500 Subject: [PATCH] Added the first version of the full-upgrade tool. This script handles a whole mess of installation that I like automatically. --- tools/full-upgrade.zsh | 105 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100755 tools/full-upgrade.zsh diff --git a/tools/full-upgrade.zsh b/tools/full-upgrade.zsh new file mode 100755 index 000000000..8fceff81b --- /dev/null +++ b/tools/full-upgrade.zsh @@ -0,0 +1,105 @@ +#!/bin/zsh + +# camperdave's full upgrade tool for oh-my-zsh. This tool updates a lot of things that might take a while, so it is seperate tool. +# Created 5/6/2011 + +# Step one: call the regular update script. +# Step two: check for a custom-overlay. If found, update that. +# Stept three: check each plugin folder, and if there's a .git folder in there, it is independently updated, so update that. + +base_upgrade(){ + if [ -z $ZSH ]; then + if [ -d "~/.oh-my-zsh" ]; then + export ZSH=~/.oh-my-zsh + fi + fi + + if [ -f "$ZSH/tools/upgrade.sh" ]; then + "$ZSH/tools/upgrade.sh" + else + echo "Upgrade script not found!" + + doFresh=1 + while [ $doFresh -eq 1 ]; do + echo -n "Do you want to install oh-my-zsh to $HOME/.oh-my-zsh? [Y/n] " + read yn + case $yn in + [Yy]* ) git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh + echo "You should go back up your old .zshrc file, and copy over the one in ~/.oh-my-zshrc/templates..." + break ;; + [Nn]* ) doFresh=0 + break ;; + * ) echo "Please answer Yes or No." + ;; + esac + done; + fi +} + + +overlay_upgrade(){ + cd "$ZSH" + echo "Looking for a custom-overlay" + git remote | grep "custom-overlay" + + if [[ $? == 0 ]]; then + echo "custom-overlay found. Perfoming update." + saveIFS=$IFS + IFS=$'\n' + + doOverlay=1 + while [ $doOverlay -eq 1 ]; do + set -A badFiles $(git pull -q --no-commit custom-overlay custom-overlay 2>&1) + + if [[ ${#badFiles} -gt 0 ]]; then + echo "$badFiles[2,${#badFiles}-2]" + echo -n "Do you want to delete the above files in order to pull down your custom overlay? [Y/n] " + read yn + case $yn in + [Yy]* ) for i in $badFiles[2,${#badFiles}-2]; do + val=$(echo $i | sed -e 's/^[ \t]*//') + rm "$val" + done; + break ;; + [Nn]* ) doOverlay=0 + break ;; + * ) echo "Please answer Yes or No." + ;; + esac + else + doOverlay=0 + fi + + done; + + IFS=$saveIFS + + + # echo $badFiles[2] + fi + + echo "custom-overlay update completed, performing plugin updates!" +} + +plugin_upgrade(){ + cd "$ZSH" + cd "plugins" + + builtin set -A list ** + + for i in $list; do + if [ -d "$i/.git" ]; then + echo "Updating $i..." + cd "$i" + git pull + cd .. + fi + done +} + + +# base_upgrade +overlay_upgrade +# plugin_upgrade + +cd "$ZSH"