1
0
Fork 0

Add update module

module/update
Sorin Ionescu 12 years ago
parent 773ca7ee50
commit 5ecbb49630

@ -0,0 +1,54 @@
#
# Updates Prezto to the latest version.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
local remote_name
local remote_branch
local auto_commit
local use_color
zstyle -s ':prezto:module:update:remote' name 'remote_name'
zstyle -s ':prezto:module:update:remote' branch 'remote_branch'
zstyle -t ':prezto:module:update' auto-commit && auto_commit='yes'
zstyle -t ':prezto:module:update:*' color && use_color='yes'
if ! git \
--git-dir="$(cd "${ZDOTDIR:-$HOME}/.zprezto" && git-root)" \
--work-tree="${ZDOTDIR:-$HOME}/.zprezto" \
pull \
$(! is-true "$auto_commit" && print '--no-commit') \
--strategy=recursive \
-X ours \
"${remote_name:-origin}" \
"${remote_branch:-master}" 2> /dev/null
then
is-true "$use_color" && printf "$FG[red]"
print 'There was an error updating. Try again later?'
is-true "$use_color" && printf "$FG[none]"
return 1
fi
is-true "$use_color" && printf "$FG[green]"
printf '%s' \
'________ _____
___ __ \___________________ /______
__ /_/ /_ ___/ _ \__ /_ __/ __ \
_ ____/_ / / __/_ /_/ /_ / /_/ /
/_/ /_/ \___/_____/\__/ \____/
'
is-true "$use_color" && printf "$FG[cyan]"
print
print 'Prezto has been updated to the latest version.'
print 'Follow me on GitHub at https://github.com/sorin-ionescu/prezto.'
if ! is-true "$auto_commit"; then
is-true "$use_color" && printf "$FG[yellow]"
print
print 'Updates must be manually commited.'
fi
print
is-true "$use_color" && printf "$FG[none]"
return 0

@ -0,0 +1,24 @@
#
# Updates Prezto periodically.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
_updater_date_file="$HOME/.zupdate"
if zstyle -t ':prezto:module:update' auto-update; then
zstyle -s ':prezto:module:update' frequency '_updater_check_frequency'
# Initialize the update reminder.
if [[ ! -f "$_updater_date_file" ]]; then
touch "$_updater_date_file"
fi
# Check for update every 7 days.
if [[ "$_updater_date_file"(Nm+$_updater_check_frequency) ]]; then
pupdate && touch "$_updater_date_file"
fi
fi
unset _updater_{date_file,check_frequency}

@ -141,3 +141,22 @@ zstyle ':prezto:module:terminal' auto-title 'yes'
# Auto start a session when Zsh is launched in a SSH connection.
# zstyle ':prezto:module:tmux:auto-start' remote 'yes'
#
# Update
#
# Auto update to the latest version.
zstyle ':prezto:module:update' auto-update 'no'
# Auto commit updated files without review.
zstyle ':prezto:module:update' auto-commit 'no'
# Set the update frequency in days.
zstyle ':prezto:module:update' check-frequency '7'
# Set the name of the update remote.
zstyle ':prezto:module:update:remote' name 'origin'
# Set the branch of the update remote.
zstyle ':prezto:module:update:remote' branch 'master'

Loading…
Cancel
Save