Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
zsh addon update check
function _do-gen-update() {
echo "Upgrading $2..."
case "$2" in
volt) volt self-upgrade -check ;;
zplugin) zplugin upgrade --all ;;
*) echo "Unknown application $2. Moving on..." ;;
esac
touch "$1"
}
function gen-update-check() {
checkfile="$HOME/.$1-update-check"
[[ -f "$checkfile" ]] || _do-gen-update "$checkfile" "$1"
eval $(stat -s "$checkfile")
#printf "now: %s\nlastcheck: %s\n" $st_atime $st_mtime
(( (st_atime - 604800) > st_mtime )) && _do-gen-update "$checkfile" "$1"
}
for p in volt zplugin; do (gen-update-check $p); done
wait
unset p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment