2022-12-07 07:30:05 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-01-21 12:18:17 +00:00
|
|
|
# This script automatically commits/pull changes to the remote repository with a generic commit message.
|
2022-12-07 07:30:05 +00:00
|
|
|
|
2023-01-21 12:18:17 +00:00
|
|
|
# It is aliased to `cs-update` in .zshrc
|
|
|
|
|
|
|
|
NOTES_PATH="/home/thomas/repos/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"
|
2022-12-07 07:30:05 +00:00
|
|
|
|
|
|
|
cd "$NOTES_PATH"
|
|
|
|
|
|
|
|
# Loop through directories and convert spaces in filenames to underscores
|
2022-12-10 12:00:05 +00:00
|
|
|
source ${SPACE_TO_UNDERSCORE}
|
2023-01-21 13:06:01 +00:00
|
|
|
source ${CLEAN_IMAGE_DIRECTORY}
|
|
|
|
|
2022-12-07 07:30:05 +00:00
|
|
|
git pull
|
|
|
|
CHANGES_EXIST="$(git status --porcelain | wc -l)"
|
|
|
|
|
|
|
|
# If no changes, exit. Else commit and push with timestamp
|
|
|
|
if [ "$CHANGES_EXIST" -eq 0 ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
git pull
|
|
|
|
git add .
|
2022-12-09 08:30:05 +00:00
|
|
|
git commit -q -m "Autosave: $(date +"%Y-%m-%d %H:%M:%S")"
|
2022-12-07 07:30:05 +00:00
|
|
|
git push -q
|