diff --git a/brethil_dotfile.sh b/brethil_dotfile.sh index df669b2..4f5eefd 100755 --- a/brethil_dotfile.sh +++ b/brethil_dotfile.sh @@ -1,6 +1,9 @@ # vim:ft=zsh ts=2 sw=2 sts=2 -# Check for update, set DISABLE_UPDATE_PROMPT=yes to disable the prompt and automatically update -env DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f "$DOTFILES/check_for_update.sh" + +# Check for update, set DISABLE_UPDATE_PROMPT=true to disable the prompt and automatically update +if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then + source "${DOTFILES}/check_for_update.sh" +fi # theme-related variables export ZSH_CUSTOM="$DOTFILES" diff --git a/check_for_update.sh b/check_for_update.sh index b88e0ff..c56db84 100755 --- a/check_for_update.sh +++ b/check_for_update.sh @@ -4,18 +4,17 @@ # First version: 14 July 2017 # Rebased on upstream: 08 December 2020 + +local DOTFILES_UPDATEFILE=${DOTFILES}/.dotfiles-update # Migrate .dotfiles-update file to $DOTFILES -if [[ -f ~/.dotfiles-update && ! -f "${DOTFILES}/.dotfiles-update" ]]; then - mv ~/.dotfiles-update "${DOTFILES}/.dotfiles-update" +if [[ -f ~/.dotfiles-update && ! -f "${DOTFILES_UPDATEFILE}" ]]; then + mv ~/.dotfiles-update "${DOTFILES_UPDATEFILE}" fi # Cancel update if: # - the automatic update is disabled. -# - the current user doesn't have write permissions nor owns the $ZSH directory. # - git is unavailable on the system. -if [[ "$DISABLE_AUTO_UPDATE" = true ]] \ - || [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \ - || ! command -v git &>/dev/null; then +if [[ "$DISABLE_DOTFILES_AUTOUPDATE" = true ]] || ! command -v git &>/dev/null; then return fi @@ -66,7 +65,7 @@ function update_dotfiles() { " EXIT INT QUIT # Create or update .zsh-update file if missing or malformed - if ! source "~/.dotfiles-update" 2>/dev/null || [[ -z "$LAST_EPOCH" ]]; then + if ! source "${DOTFILES_UPDATEFILE}" 2>/dev/null || [[ -z "$LAST_EPOCH" ]]; then _update_dotfiles_update return fi