Adds options for update check
If the env variable UPDATE_CHECK is set to "daily", "weekly" or "monthly", there will be a message if you're late on your update. If the env variable UPDATE_CHECK_ALWAYS is set to "true", you will get a message telling you that your system is up to date.
This commit is contained in:
parent
b71d8f6e6d
commit
0fa53b8b95
|
@ -1,3 +1,3 @@
|
|||
zsh/extraconfig.zsh
|
||||
|
||||
zsh/env.zsh
|
||||
.data
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
_date_format() {
|
||||
|
||||
case $UPDATE_CHECK in
|
||||
"daily") echo +%d/%m/%Y;;
|
||||
"weekly") echo +%V/%Y;;
|
||||
"monthly") echo +%m/%Y;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
_check_date_file() {
|
||||
mkdir -p ~/.config/dotfiles/.data
|
||||
touch ~/.config/dotfiles/.data/update_date
|
||||
|
@ -32,14 +42,15 @@ _sentence() {
|
|||
}
|
||||
|
||||
_check_date() {
|
||||
|
||||
_check_date_file
|
||||
|
||||
old_date=`cat ~/.config/dotfiles/.data/update_date`
|
||||
new_date=`date +%d/%m/%y`
|
||||
new_date=`date $1`
|
||||
|
||||
if [ "$new_date" != "$old_date" ]; then
|
||||
_sentence not_updated
|
||||
else
|
||||
elif [ "$UPDATE_CHECK_ALWAYS" == "true" ]; then
|
||||
_sentence updated
|
||||
fi
|
||||
}
|
||||
|
@ -207,6 +218,19 @@ update() {
|
|||
formatted=`date -ud "@$seconds" +'%H hours %M minutes %S seconds'`
|
||||
echo "\033[32;1m=== Update finished in $formatted ===\033[0m"
|
||||
|
||||
_check_date_file
|
||||
date +%d/%m/%y > ~/.config/dotfiles/.data/update_date
|
||||
format=`_date_format`
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
_check_date_file
|
||||
date $format > ~/.config/dotfiles/.data/update_date
|
||||
fi
|
||||
}
|
||||
|
||||
# Spawn anonymous function
|
||||
function() {
|
||||
local format=`_date_format`
|
||||
|
||||
if [ "$format" != "" ]; then
|
||||
_check_date $format
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue