Created
July 31, 2012 07:52
-
-
Save osyoyu/3214684 to your computer and use it in GitHub Desktop.
CheckPacman
This file contains 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
#!/bin/zsh | |
# add the line under to your zshrc: | |
# source checkpacman.zsh | |
rnd=$(( (RANDOM % 5) )) | |
if [ $rnd -ne 0 ]; then | |
return | |
else | |
echo "Checking the time of last update..." | |
fi | |
while read line; do | |
if [[ `echo "$line" | sed -e "s/: [0-9]*:.*;\(.*\)/\1/"` =~ .*pacman\ -Syu.* ]]; then | |
# echo $line | |
typeset -i LASTRUN=`echo "$line" | sed -e 's/: \(.*\):.*;.*/\1/'` | |
typeset -i DATENOW=`date +%s` | |
typeset -i INTERVAL=`expr $DATENOW - $LASTRUN` | |
if [ ${INTERVAL} -gt 604800 ]; then | |
flag="1" | |
else | |
flag="0" | |
fi | |
if [ ${flag} -eq 1 ]; then | |
echo "It's time to update your system." | |
fi | |
fi | |
done < $HISTFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment