summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/check_for_upgrade.sh33
-rwxr-xr-xtools/install.sh12
-rw-r--r--tools/uninstall.sh18
-rw-r--r--tools/upgrade.sh28
4 files changed, 63 insertions, 28 deletions
diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh
index aeaa0e415..581f03a07 100644
--- a/tools/check_for_upgrade.sh
+++ b/tools/check_for_upgrade.sh
@@ -8,6 +8,18 @@ function _update_zsh_update() {
echo "LAST_EPOCH=$(_current_epoch)" > ~/.zsh-update
}
+function _upgrade_zsh() {
+ /usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh
+ # update the zsh file
+ _update_zsh_update
+}
+
+epoch_target=$UPDATE_ZSH_DAYS
+if [[ -z "$epoch_target" ]]; then
+ # Default to old behavior
+ epoch_target=13
+fi
+
if [ -f ~/.zsh-update ]
then
. ~/.zsh-update
@@ -17,19 +29,24 @@ then
fi
epoch_diff=$(($(_current_epoch) - $LAST_EPOCH))
- if [ $epoch_diff -gt 6 ]
+ if [ $epoch_diff -gt $epoch_target ]
then
- echo "[Oh My Zsh] Would you like to check for updates?"
- echo "Type Y to update oh-my-zsh: \c"
- read line
- if [ "$line" = Y ] || [ "$line" = y ]
+ if [ "$DISABLE_UPDATE_PROMPT" = "true" ]
then
- /usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh
- # update the zsh file
- _update_zsh_update
+ _upgrade_zsh
+ else
+ echo "[Oh My Zsh] Would you like to check for updates?"
+ echo "Type Y to update oh-my-zsh: \c"
+ read line
+ if [ "$line" = Y ] || [ "$line" = y ]; then
+ _upgrade_zsh
+ else
+ _update_zsh_update
+ fi
fi
fi
else
# create the zsh file
_update_zsh_update
fi
+
diff --git a/tools/install.sh b/tools/install.sh
index aedb706da..a2bd5665a 100755
--- a/tools/install.sh
+++ b/tools/install.sh
@@ -5,21 +5,23 @@ then
fi
echo "\033[0;34mCloning Oh My Zsh...\033[0m"
-/usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
+hash git >/dev/null && /usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh || {
+ echo "git not installed"
+ exit
+}
echo "\033[0;34mLooking for an existing zsh config...\033[0m"
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]
then
- echo "\033[0;33mFound ~/.zshrc.\033[0m \033[0;32]Backing up to ~/.zshrc.pre-oh-my-zsh\033[0m";
- cp ~/.zshrc ~/.zshrc.pre-oh-my-zsh;
- rm ~/.zshrc;
+ echo "\033[0;33mFound ~/.zshrc.\033[0m \033[0;32mBacking up to ~/.zshrc.pre-oh-my-zsh\033[0m";
+ mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh;
fi
echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m"
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m"
-echo "export PATH=$PATH" >> ~/.zshrc
+echo "export PATH=\$PATH:$PATH" >> ~/.zshrc
echo "\033[0;34mTime to change your default shell to zsh!\033[0m"
chsh -s `which zsh`
diff --git a/tools/uninstall.sh b/tools/uninstall.sh
index 8ff583322..41d601576 100644
--- a/tools/uninstall.sh
+++ b/tools/uninstall.sh
@@ -4,12 +4,20 @@ then
rm -rf ~/.oh-my-zsh
fi
-echo "Looking for an existing zsh config..."
+echo "Looking for original zsh config..."
if [ -f ~/.zshrc.pre-oh-my-zsh ] || [ -h ~/.zshrc.pre-oh-my-zsh ]
then
- echo "Found ~/.zshrc. Backing up to ~/.zshrc.pre-oh-my-zsh";
- rm ~/.zshrc;
- cp ~/.zshrc.pre-oh-my-zsh ~/.zshrc;
+ echo "Found ~/.zshrc.pre-oh-my-zsh -- Restoring to ~/.zshrc";
+
+ if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]
+ then
+ ZSHRC_SAVE=".zshrc.omz-uninstalled-`date +%Y%m%d%H%M%S`";
+ echo "Found ~/.zshrc -- Renaming to ~/${ZSHRC_SAVE}";
+ mv ~/.zshrc ~/${ZSHRC_SAVE};
+ fi
+
+ mv ~/.zshrc.pre-oh-my-zsh ~/.zshrc;
+
source ~/.zshrc;
else
echo "Switching back to bash"
@@ -17,4 +25,4 @@ else
source /etc/profile
fi
-echo "Thanks for trying out Oh My Zsh. It's been uninstalled." \ No newline at end of file
+echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
diff --git a/tools/upgrade.sh b/tools/upgrade.sh
index 52a8cc4da..0aeebdebf 100644
--- a/tools/upgrade.sh
+++ b/tools/upgrade.sh
@@ -1,12 +1,20 @@
current_path=`pwd`
-echo -e "\033[0;34mUpgrading Oh My Zsh\033[0m"
-( cd $ZSH && git pull origin master )
-echo -e "\033[0;32m"' __ __ '"\033[0m"
-echo -e "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m"
-echo -e "\033[0;32m"' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '"\033[0m"
-echo -e "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m"
-echo -e "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m"
-echo -e "\033[0;32m"' /____/ '"\033[0m"
-echo -e "\033[0;34mHooray! Oh My Zsh has been updated and/or is at the current version.\033[0m"
-echo -e "\033[0;34mTo keep up on the latest, be sure to follow Oh My Zsh on twitter: \033[1mhttp://twitter.com/ohmyzsh\033[0m"
+current_path=${current_path/ /\\ }
+printf '\033[0;34m%s\033[0m\n' "Upgrading Oh My Zsh"
+cd "$ZSH"
+
+if git pull origin master
+then
+ printf '\033[0;32m%s\033[0m\n' ' __ __ '
+ printf '\033[0;32m%s\033[0m\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
+ printf '\033[0;32m%s\033[0m\n' ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
+ printf '\033[0;32m%s\033[0m\n' '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '
+ printf '\033[0;32m%s\033[0m\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
+ printf '\033[0;32m%s\033[0m\n' ' /____/ '
+ printf '\033[0;34m%s\033[0m\n' 'Hooray! Oh My Zsh has been updated and/or is at the current version.'
+ printf '\033[0;34m%s\033[1m%s\033[0m\n' 'To keep up on the latest, be sure to follow Oh My Zsh on twitter: ' 'http://twitter.com/ohmyzsh'
+else
+ printf '\033[0;31m%s\033[0m\n' 'There was an error updating. Try again later?'
+fi
+
cd "$current_path"