Skip to content

Instantly share code, notes, and snippets.

@hawko2600
Last active June 30, 2018 05:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hawko2600/4f6c71248e76c3c886164bcc3b899c3a to your computer and use it in GitHub Desktop.
Save hawko2600/4f6c71248e76c3c886164bcc3b899c3a to your computer and use it in GitHub Desktop.
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