prezto/functions/update-omz
2012-01-29 23:14:36 -05:00

32 lines
1 KiB
Text
Executable file

# Update OMZ
# Jonathan Dahan <jonathan@jedahan.com>
# There are two options that can be added to your zshrc
#
# If upstream is a branch other than origin, add
#
# zstyle ':omz:function:update-omz' upstream 'my-upstream-branch'
#
# To automatically commit from upstream, add
#
# zstyle ':omz:function:update-omz' auto-commit 'yes'
#
# If you really need auto-updating and do not care about losing data, try
#
# ( [ ! -f ~/.omz-update ] || [ ~/.omz-update(Nmh+6) ] ) && update-omz && touch ~/.omz-update
current_path=$PWD
cd $OMZ_HOME
zstyle -t ':omz:function:update-omz' auto-commit || local nocommit='--no-commit'
zstyle -t ':omz:function:update-omz' upstream '_upstream'
if git pull $nocommit --strategy=recursive -X ours ${_upstream:-origin} master; then
zstyle -t ':omz:function:update-omz' color && printf "$FG[blue]"
printf 'Hooray! oh-my-zsh is up-to-date :)'
else
zstyle -t ':omz:function:update-omz' color && printf "$FG[red]"
printf 'Oh no! There was an error updating oh-my-zsh :('
fi
cd "$current_path"