diff --git a/check_for_upgrade.sh b/check_for_upgrade.sh index 53451d8..e0d77dc 100755 --- a/check_for_upgrade.sh +++ b/check_for_upgrade.sh @@ -11,25 +11,26 @@ function _update_dotfiles_update() { } function _upgrade_dotfiles() { - env DOTFILES=$DOTFILES sh $DOTFILES/upgrade.sh + env _DOTFILES=$_DOTFILES sh $_DOTFILES/upgrade.sh # update the zsh file - _update_zsh_update + _update_dotfiles_update } -epoch_target=$UPDATE_ZSH_DAYS +# Configure this in shell/env +epoch_target=$UPDATE_DOTFILES_DAYS if [[ -z "$epoch_target" ]]; then - # Default to old behavior + # Default to every 2 weeks epoch_target=13 fi # Cancel upgrade if the current user doesn't have write permissions for the # dotfiles directory. -[[ -w "$DOTFILES" ]] || return 0 +[[ -w "$_DOTFILES" ]] || echo "You can't write to $(dotfiles)"; return 1 # Cancel upgrade if git is unavailable on the system -whence git >/dev/null || return 0 +whence git >/dev/null || echo "git is not available"; return 2 -if mkdir "$DOTFILES/log/update.lock" 2>/dev/null; then +if mkdir "$_DOTFILES/log/update.lock" 2>/dev/null; then if [ -f ~/.dotfiles-update ]; then . ~/.dotfiles-update @@ -56,5 +57,5 @@ if mkdir "$DOTFILES/log/update.lock" 2>/dev/null; then _update_dotfiles_update fi - rmdir $DOTFILES/log/update.lock + rmdir $_DOTFILES/log/update.lock fi diff --git a/shell/env b/shell/env index 248534a..c75860b 100644 --- a/shell/env +++ b/shell/env @@ -6,14 +6,18 @@ export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 export LANGUAGE=en_US.UTF-8 -export DOTFILES="${HOME}/dotfiles" - # Paths export PATH=$PATH:${HOME}/bin:/usr/lib/wine/bin:/sbin:/usr/sbin:/usr/local/bin +# Give the path to the dotfiles +export _DOTFILES="${HOME}/dotfiles" + # Allow automatic updates export DISABLE_DOTFILES_AUTO_UPDATE="FALSE" +# Update every 2 weeks (OMZ default) +export UPDATE_DOTFILES_DAYS=13 + # Automatically attach tmux session "C0DE" upon entering a shell if [[ -z "$TMUX" ]]; then tmux attach -t C0DE || tmux new -s C0DE diff --git a/upgrade.sh b/upgrade.sh index 2c69403..54eac1b 100755 --- a/upgrade.sh +++ b/upgrade.sh @@ -21,7 +21,7 @@ else fi printf "${BLUE}%s${NORMAL}\n" "Updating your dotfiles" -cd "$DOTFILES" +cd "$_DOTFILES" branch=$(git name-rev --name-only HEAD) if git pull --rebase --stat origin $branch then