From ac97e2681da32a83789810e73a1558d2a3a3c602 Mon Sep 17 00:00:00 2001 From: thomasabishop Date: Mon, 23 Jan 2023 15:53:41 +0000 Subject: [PATCH] Autosave: 2023-01-23 15:53:41 --- _scripts/auto_save.sh | 4 ++-- _scripts/auto_save_mac.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100755 _scripts/auto_save_mac.sh diff --git a/_scripts/auto_save.sh b/_scripts/auto_save.sh index 5820617..340dabf 100755 --- a/_scripts/auto_save.sh +++ b/_scripts/auto_save.sh @@ -5,8 +5,8 @@ # It is aliased to `cs-update` in .zshrc NOTES_PATH="/Users/thomasbishop/prepos/computer_science" -# SPACE_TO_UNDERSCORE="/home/thomas/repos/computer_science/_scripts/space_to_underscore_filename.sh" -# CLEAN_IMAGE_DIRECTORY="/home/thomas/repos/computer_science/_scripts/clean_image_directory.sh" +SPACE_TO_UNDERSCORE="/home/thomas/repos/computer_science/_scripts/space_to_underscore_filename.sh" +CLEAN_IMAGE_DIRECTORY="/home/thomas/repos/computer_science/_scripts/clean_image_directory.sh" cd "$NOTES_PATH" diff --git a/_scripts/auto_save_mac.sh b/_scripts/auto_save_mac.sh new file mode 100755 index 0000000..03e5928 --- /dev/null +++ b/_scripts/auto_save_mac.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# This script automatically commits/pull changes to the remote repository with a generic commit message. + +# It is aliased to `cs-update` in .zshrc + +NOTES_PATH="/Users/thomasbishop/prepos/computer_science" +# SPACE_TO_UNDERSCORE="/home/thomas/repos/computer_science/_scripts/space_to_underscore_filename.sh" +# CLEAN_IMAGE_DIRECTORY="/home/thomas/repos/computer_science/_scripts/clean_image_directory.sh" + +cd "$NOTES_PATH" + +# Loop through directories and convert spaces in filenames to underscores +# source ${SPACE_TO_UNDERSCORE} +# source ${CLEAN_IMAGE_DIRECTORY} + +git pull >/dev/null 2>&1 + +CHANGES_EXIST="$(git status --porcelain | wc -l)" + +# If no changes, exit. Else commit and push with timestamp +if [ "$CHANGES_EXIST" -eq 0 ]; then + echo "No changes" + exit 0 +fi + +git pull >/dev/null 2>&1 +git add . +git commit -q -m "Autosave: $(date +"%Y-%m-%d %H:%M:%S")" +git push