From 2bbd42f5de1e1e977b42dd89dd23608d90118acd Mon Sep 17 00:00:00 2001 From: thomasabishop Date: Tue, 21 Feb 2023 07:39:26 +0000 Subject: [PATCH] Autosave: 2023-02-21 07:39:26 --- _scripts/auto_save.sh | 16 ++++++++-------- _scripts/auto_save_mac.sh | 8 ++++---- _scripts/random_revision_topic.sh | 10 +++++----- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/_scripts/auto_save.sh b/_scripts/auto_save.sh index 6b693b8..2c44371 100755 --- a/_scripts/auto_save.sh +++ b/_scripts/auto_save.sh @@ -4,22 +4,22 @@ # 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" +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" -cd "$NOTES_PATH" +cd "$notes_path" # Loop through directories and convert spaces in filenames to underscores -source ${SPACE_TO_UNDERSCORE} -source ${CLEAN_IMAGE_DIRECTORY} +source ${space_to_underscore} +source ${clean_image_directory} git pull >/dev/null 2>&1 -CHANGES_EXIST="$(git status --porcelain | wc -l)" +changes_exist="$(git status --porcelain | wc -l)" # If no changes, exit. Else commit and push with timestamp -if [ "$CHANGES_EXIST" -eq 0 ]; then +if [ "$changes_exist" -eq 0 ]; then echo "No changes" exit 0 fi diff --git a/_scripts/auto_save_mac.sh b/_scripts/auto_save_mac.sh index 03e5928..12cc9aa 100755 --- a/_scripts/auto_save_mac.sh +++ b/_scripts/auto_save_mac.sh @@ -4,11 +4,11 @@ # It is aliased to `cs-update` in .zshrc -NOTES_PATH="/Users/thomasbishop/prepos/computer_science" +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" +cd "$notes_path" # Loop through directories and convert spaces in filenames to underscores # source ${SPACE_TO_UNDERSCORE} @@ -16,10 +16,10 @@ cd "$NOTES_PATH" git pull >/dev/null 2>&1 -CHANGES_EXIST="$(git status --porcelain | wc -l)" +changes_exist="$(git status --porcelain | wc -l)" # If no changes, exit. Else commit and push with timestamp -if [ "$CHANGES_EXIST" -eq 0 ]; then +if [ "$changes_exist" -eq 0 ]; then echo "No changes" exit 0 fi diff --git a/_scripts/random_revision_topic.sh b/_scripts/random_revision_topic.sh index 2ebb32d..f415856 100755 --- a/_scripts/random_revision_topic.sh +++ b/_scripts/random_revision_topic.sh @@ -5,15 +5,15 @@ # It is aliased to cs-revise in .zshrc # Choose source directories... -DIRS_TO_PARSE="../Computer_Architecture ../Databases ../Electronics_and_Hardware ../Operating_Systems ../Programming_Languages/Shell ../Logic" +directories_to_parse="../Computer_Architecture ../Databases ../Electronics_and_Hardware ../Operating_Systems ../Programming_Languages/Shell ../Logic" # Return array of all files belonging to source dirs... -for ele in $DIRS_TO_PARSE; do - FILE_MATCHES+=( $(find $ele -name "*.md" -type f) ) +for ele in $directories_to_parse; do + file_matches+=( $(find $ele -name "*.md" -type f) ) done # Generate a random integer between 0 and the match array length... -RANDOM_FILE_INDEX=$(( $RANDOM % ${#FILE_MATCHES[@]} + 0 )) +random_file_index=$(( $RANDOM % ${#file_matches[@]} + 0 )) # Return file matching that index... -echo "Revise this topic: ${FILE_MATCHES[$RANDOM_FILE_INDEX]}" +echo "Revise this topic: ${file_matches[$random_file_index]}"