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 ;;