From 04e4d59435b01b62f697663fd732d68d300b65ec Mon Sep 17 00:00:00 2001 From: hanez Date: Wed, 10 Sep 2025 00:32:22 +0200 Subject: [PATCH] home.sh update. --- .zsh/functions.d/home.sh | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/.zsh/functions.d/home.sh b/.zsh/functions.d/home.sh index dd3ed23c..1ab33764 100644 --- a/.zsh/functions.d/home.sh +++ b/.zsh/functions.d/home.sh @@ -34,20 +34,28 @@ function home() { ;; up) cd ~ - last_update=$(stat -c %Y .lastupdate) - echo "Last configuration update: $last_update" - current_date=$(date +%s) - echo "Current date: $current_date" - time_diff=$(($current_date-$last_update)) - echo "Time difference: $time_diff" - if (( time_diff > 86400 )) || [ "$2" = "f" ]; then - echo "Doing home up..." - git pull - git submodule update --init --recursive - touch .lastupdate + if test -f .lastupdate; then + last_update=$(stat -c %Y .lastupdate) + echo "Last configuration update: $last_update" + current_date=$(date +%s) + echo "Current date: $current_date" + time_diff=$(($current_date-$last_update)) + echo "Time difference: $time_diff" + if (( time_diff > 86400 )) || [ "$2" = "f" ]; then + echo "Updating home configuration..." + if git pull; then + if git submodule update --init --recursive; then + touch .lastupdate + fi + fi + else + echo "/home/hanez was already updated in the last 24 hours." + echo "Run this to force updating: home up f" + fi else - echo "/home/hanez was already updated in the last 24 hours." - echo "Run this to force updating: home up f" + echo "~/.lastupdate does not exist!" + echo "Running: home up f now..." + touch .lastupdate fi cd $OLDPWD ;;