Last active
June 30, 2018 05:55
-
-
Save hawko2600/4f6c71248e76c3c886164bcc3b899c3a to your computer and use it in GitHub Desktop.
zsh addon update check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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