Skip to content

Instantly share code, notes, and snippets.

@osyoyu
Created July 31, 2012 07:52
Show Gist options
  • Save osyoyu/3214684 to your computer and use it in GitHub Desktop.
Save osyoyu/3214684 to your computer and use it in GitHub Desktop.
CheckPacman
#!/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