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