mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-01 04:30:37 +02:00
Implement a lockfile to alleviate update prompt in multiple terminals (fixes #3766)
This commit is contained in:
parent
f39dcfda8d
commit
9407fad1f4
1 changed files with 12 additions and 0 deletions
|
|
@ -10,10 +10,19 @@ function _update_zsh_update() {
|
|||
echo "LAST_EPOCH=$(_current_epoch)" >! ~/.zsh-update
|
||||
}
|
||||
|
||||
function _create_lock() {
|
||||
touch ~/.zsh-update.lock
|
||||
}
|
||||
function _remove_lock() {
|
||||
rm ~/.zsh-update.lock
|
||||
}
|
||||
|
||||
function _upgrade_zsh() {
|
||||
_create_lock
|
||||
env ZSH=$ZSH sh $ZSH/tools/upgrade.sh
|
||||
# update the zsh file
|
||||
_update_zsh_update
|
||||
_remove_lock
|
||||
}
|
||||
|
||||
epoch_target=$UPDATE_ZSH_DAYS
|
||||
|
|
@ -22,6 +31,9 @@ if [[ -z "$epoch_target" ]]; then
|
|||
epoch_target=13
|
||||
fi
|
||||
|
||||
# Cancel upgrade if upgrade is already in progress
|
||||
[[ ! -f ~/.zsh-update.lock ]] || return 0
|
||||
|
||||
# Cancel upgrade if the current user doesn't have write permissions for the
|
||||
# oh-my-zsh directory.
|
||||
[[ -w "$ZSH" ]] || return 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue