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/extraconfig.zsh
|
||||||
|
zsh/env.zsh
|
||||||
.data
|
.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() {
|
_check_date_file() {
|
||||||
mkdir -p ~/.config/dotfiles/.data
|
mkdir -p ~/.config/dotfiles/.data
|
||||||
touch ~/.config/dotfiles/.data/update_date
|
touch ~/.config/dotfiles/.data/update_date
|
||||||
|
@ -32,14 +42,15 @@ _sentence() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_check_date() {
|
_check_date() {
|
||||||
|
|
||||||
_check_date_file
|
_check_date_file
|
||||||
|
|
||||||
old_date=`cat ~/.config/dotfiles/.data/update_date`
|
old_date=`cat ~/.config/dotfiles/.data/update_date`
|
||||||
new_date=`date +%d/%m/%y`
|
new_date=`date $1`
|
||||||
|
|
||||||
if [ "$new_date" != "$old_date" ]; then
|
if [ "$new_date" != "$old_date" ]; then
|
||||||
_sentence not_updated
|
_sentence not_updated
|
||||||
else
|
elif [ "$UPDATE_CHECK_ALWAYS" == "true" ]; then
|
||||||
_sentence updated
|
_sentence updated
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -207,6 +218,19 @@ update() {
|
||||||
formatted=`date -ud "@$seconds" +'%H hours %M minutes %S seconds'`
|
formatted=`date -ud "@$seconds" +'%H hours %M minutes %S seconds'`
|
||||||
echo "\033[32;1m=== Update finished in $formatted ===\033[0m"
|
echo "\033[32;1m=== Update finished in $formatted ===\033[0m"
|
||||||
|
|
||||||
_check_date_file
|
format=`_date_format`
|
||||||
date +%d/%m/%y > ~/.config/dotfiles/.data/update_date
|
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
|
4
zshrc
4
zshrc
|
@ -10,6 +10,10 @@ ZSH_CUSTOM=$HOME/.config/dotfiles/zsh/oh-my-zsh
|
||||||
|
|
||||||
ZSH_THEME="laptop"
|
ZSH_THEME="laptop"
|
||||||
|
|
||||||
|
if [ -f $DOTFILES/zsh/env.zsh ]; then
|
||||||
|
source $DOTFILES/zsh/env.zsh
|
||||||
|
fi
|
||||||
|
|
||||||
source $DOTFILES/zsh/config.zsh
|
source $DOTFILES/zsh/config.zsh
|
||||||
source $DOTFILES/zsh/path.zsh
|
source $DOTFILES/zsh/path.zsh
|
||||||
source $DOTFILES/zsh/exports.zsh
|
source $DOTFILES/zsh/exports.zsh
|
||||||
|
|
Loading…
Reference in New Issue