From 8559ad0ce7c44ce5b5235f8089df66644a2bf098 Mon Sep 17 00:00:00 2001 From: Jonathan Dahan Date: Thu, 26 Jan 2012 13:46:50 -0500 Subject: [PATCH] rename to omz-update --- plugins/auto-update/init.zsh | 40 ++++++++++++++++++++++++++++++++ plugins/upgrade/init.zsh | 45 ------------------------------------ 2 files changed, 40 insertions(+), 45 deletions(-) create mode 100644 plugins/auto-update/init.zsh delete mode 100644 plugins/upgrade/init.zsh diff --git a/plugins/auto-update/init.zsh b/plugins/auto-update/init.zsh new file mode 100644 index 00000000..7f37f35c --- /dev/null +++ b/plugins/auto-update/init.zsh @@ -0,0 +1,40 @@ +# Updates oh-my-zsh. +# Jonathan Dahan + +# This plugin adds auto-update support to omz. +# +# zstyle ':omz:plugin:update-omz' auto-commit 'yes' +# auto-commit will commit whatever upstream changes there are without review +# This will still favor local changes when conflict arive +# +# zstyle ':omz:plugin:update-omz' auto-update 'yes' +# auto-update will check for updates 6 hours from the last successful upgrade + +function update-omz() { + current_path=$PWD + cd $HOME/.oh-my-zsh + + zstyle -t ':omz:plugin:update-omz' auto-commit || local nocommit='--no-commit' + + if git pull $nocommit --strategy=recursive -X ours origin master; then + zstyle -t ':omz:plugin:update-omz' color && printf "$FG[blue]" + printf 'Hooray! oh-my-zsh is up-to-date :)' + touch ~/.omz-update + else + zstyle -t ':omz:plugin:update-omz' color && printf "$FG[red]" + printf 'Oh no! There was an error updating oh-my-zsh :(' + fi + + cd "$current_path" +} + +if zstyle -t ':omz:plugin:update-omz' auto-update; then + if [ -f ~/.omz-update ]; then + # update if ~/.omz-update was modified over 6 hours ago + if [ ~/.omz-update(Nmh+6) ]; then + update-omz + fi + else + update-omz + fi +fi diff --git a/plugins/upgrade/init.zsh b/plugins/upgrade/init.zsh deleted file mode 100644 index eecf1406..00000000 --- a/plugins/upgrade/init.zsh +++ /dev/null @@ -1,45 +0,0 @@ -# ------------------------------------------------------------------------------ -# FILE: upgrade-oh-my-zsh.plugin.zsh -# DESCRIPTION: oh-my-zsh plugin file. -# AUTHOR: Jonathan Dahan -# VERSION: 0.3.0 -# ------------------------------------------------------------------------------ - -# This plugin adds upgrade_zsh(), a relatively safe manual upgrade. -# It also has two dangerous options that are off by default. -# -# zstyle ':omz:plugin:upgrade' auto-commit 'yes' -# auto-commit will commit whatever upstream changes there are without review -# This will still favor local changes when conflict arive -# -# zstyle ':omz:plugin:upgrade' auto-upgrade 'yes' -# auto-upgrade will check for updates 6 hours from the last successful upgrade - -function upgrade_zsh() { - cd ~/.oh-my-zsh - current_path=$PWD - - zstyle -t ':omz:plugin:update-omz' auto-commit || local nocommit='--no-commit' - - if git pull $nocommit --strategy=recursive -X ours origin master; then - zstyle -t ':omz:plugin:update-omz' color && printf "$FG[blue]" - printf 'Hooray! oh-my-zsh is up-to-date :)' - touch ~/.zsh-upgrade - else - printf 'Oh no! There was an error upgrading oh-my-zsh :(' - zstyle -t ':omz:plugin:update-omz' color && printf "$FG[red]" - fi - - cd "$current_path" -} - -if zstyle -t ':omz:plugin:upgrade' auto-upgrade; then - if [ -f ~/.zsh-upgrade ]; then - # upgrade if ~/.zsh-update was modified over 6 hours ago - if [ ~/.zsh-upgrade(Nmh+6) ]; then - upgrade_zsh - fi - else - upgrade_zsh - fi -fi