This commit is contained in:
quackerd 2021-03-08 06:21:16 -05:00
parent c054da7450
commit a4704b70cf

View File

@ -35,6 +35,10 @@ function ozsh_load {
fi
}
function ozsh_write_update_date {
echo $(date +%Y-%m-%d) > "$OZSH_LASTUPDATE_FILE"
}
function ozsh_update {
git -C $OZSH_HOME stash
git -C $OZSH_HOME pull --rebase
@ -47,11 +51,17 @@ function ozsh_update {
git -C $d pull --rebase
done
echo $(date +%Y-%m-%d) > "$OZSH_LASTUPDATE_FILE"
ozsh_write_update_date
}
function ozsh_autoupdate {
local timediff=$(( ( $(strftime -r %Y-%m-%d $(date +%Y-%m-%d)) - $(strftime -r %Y-%m-%d $(cat $OZSH_LASTUPDATE_FILE)) ) / 86400 ))
if [ ! $? -eq 0 ]; then
# recreate the file if the command fails
ozsh_write_update_date
fi
if [ "$timediff" -ge "7" ]; then
vared -p 'Would you like to update ozsh? [y/N]: ' -c answer
if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
@ -68,7 +78,7 @@ function ozsh_init {
# create lastupdate file if not exist
if [ ! -f $OZSH_LASTUPDATE_FILE ]; then
echo $(date +%Y-%m-%d) > $OZSH_LASTUPDATE_FILE
ozsh_write_update_date
fi
# load the datetime module