Added auto update.
This commit is contained in:
parent
da080852bc
commit
82fe11ee1b
3 changed files with 76 additions and 0 deletions
49
functions/omz-update
Normal file
49
functions/omz-update
Normal file
|
@ -0,0 +1,49 @@
|
|||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
|
||||
local remote_name
|
||||
local remote_branch
|
||||
local auto_commit
|
||||
local use_color
|
||||
|
||||
zstyle -s ':omz:updater:remote' name 'remote_name'
|
||||
zstyle -s ':omz:updater:remote' branch 'remote_branch'
|
||||
zstyle -t ':omz:updater:auto' commit && auto_commit='yes'
|
||||
zstyle -t ':omz:updater:*' color && use_color='yes'
|
||||
|
||||
if ! git \
|
||||
--git-dir="${OMZ}/.git" \
|
||||
--work-tree="$OMZ" \
|
||||
pull \
|
||||
"${auto_commit:---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 'Oh My Zsh has been updated to the latest version.'
|
||||
print 'Follow us on Twitter: http://twitter.com/ohmyzsh.'
|
||||
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
|
15
init.zsh
15
init.zsh
|
@ -88,6 +88,21 @@ zstyle -a ':omz:prompt' theme 'prompt_argv'
|
|||
prompt "$prompt_argv[@]"
|
||||
unset prompt_argv
|
||||
|
||||
# Auto-update Zsh every week.
|
||||
omz_update="$HOME/.zomzupdate"
|
||||
if zstyle -t ':omz:updater:auto' update; then
|
||||
# Initialize the update reminder.
|
||||
if [[ ! -f "$omz_update" ]]; then
|
||||
touch "$omz_update"
|
||||
fi
|
||||
|
||||
# Check for update every 7 days.
|
||||
if [ "$omz_update"(Nmd+7) ]; then
|
||||
update-omz && touch "$omz_update"
|
||||
fi
|
||||
fi
|
||||
unset omz_update
|
||||
|
||||
# Compile the completion dump, to increase startup speed.
|
||||
dump_file="$HOME/.zcompdump"
|
||||
if [[ "$dump_file" -nt "${dump_file}.zwc" || ! -f "${dump_file}.zwc" ]]; then
|
||||
|
|
|
@ -21,6 +21,18 @@ zstyle ':omz:load' plugin 'archive' 'git'
|
|||
# Auto set to 'off' on dumb terminals.
|
||||
zstyle ':omz:prompt' theme 'sorin'
|
||||
|
||||
# Auto update to the latest version.
|
||||
zstyle ':omz:updater:auto' update 'no'
|
||||
|
||||
# Auto commit updated files without review.
|
||||
zstyle ':omz:updater:auto' commit 'no'
|
||||
|
||||
# Set the name of the update remote.
|
||||
zstyle ':omz:updater:remote' name 'origin'
|
||||
|
||||
# Set the branch of the update remote.
|
||||
zstyle ':omz:updater:remote' branch 'master'
|
||||
|
||||
# This will make you shout: OH MY ZSHELL!
|
||||
source "$HOME/.oh-my-zsh/init.zsh"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue