Commit 494f57b1 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

prompt to auto-update dotfiles

parent c890b5fe
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -11,6 +11,8 @@ fi

. ~/.shell/funcs

do_update

# Source global definitions
# (debian global bashrc has a bad habit of setting PS1, so store and revert 
# after)
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
# flags, timestamps
/.sudo_as_admin_successful
/.zsh-update
/.shell/.update

# other version control systems
.svn/
+27 −0
Original line number Diff line number Diff line
@@ -52,3 +52,30 @@ manage_path()
	done
	eval $var="'${pre:+$pre:}$val${post:+:$post}'"
}

do_update()
{
	local timestamp=${HOME}/.shell/.update
	local now=`date +%s` updated=`date -r $timestamp +%s 2>/dev/null`
	local BOLD_BLUE=$'\033[34;1m' DEFAULT=$'\033[m'
	local prompt="${BOLD_BLUE}Would you like to update dotfiles?${DEFAULT} "

	if [ $now -lt $((updated + 604800)) ]; then
		return
	fi

	touch "$timestamp"

	case $0 in
		*zsh) read "?$prompt" ans ;;
		*) read -p "$prompt" ans ;;
	esac
	case "$ans" in
		[Yy]|[Yy][Ee][Ss]) ;;
		*) return ;;
	esac

	cd ~
	git pull origin --ff-only
	cd - >/dev/null
}
+2 −0
Original line number Diff line number Diff line
source ~/.shell/funcs

do_update

plugins+=(git django pip python)
plugins+=(virtualenv virtualenvwrapper tmux-virtualenvwrapper)