Autosave: 2023-02-21 07:39:26

This commit is contained in:
thomasabishop 2023-02-21 07:39:26 +00:00
parent 50f9cef354
commit 2bbd42f5de
3 changed files with 17 additions and 17 deletions

View file

@ -4,22 +4,22 @@
# It is aliased to `cs-update` in .zshrc # It is aliased to `cs-update` in .zshrc
NOTES_PATH="/home/thomas/repos/computer_science" notes_path="/home/thomas/repos/computer_science"
SPACE_TO_UNDERSCORE="/home/thomas/repos/computer_science/_scripts/space_to_underscore_filename.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" 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 # Loop through directories and convert spaces in filenames to underscores
source ${SPACE_TO_UNDERSCORE} source ${space_to_underscore}
source ${CLEAN_IMAGE_DIRECTORY} source ${clean_image_directory}
git pull >/dev/null 2>&1 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 no changes, exit. Else commit and push with timestamp
if [ "$CHANGES_EXIST" -eq 0 ]; then if [ "$changes_exist" -eq 0 ]; then
echo "No changes" echo "No changes"
exit 0 exit 0
fi fi

View file

@ -4,11 +4,11 @@
# It is aliased to `cs-update` in .zshrc # 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" # 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" # 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 # Loop through directories and convert spaces in filenames to underscores
# source ${SPACE_TO_UNDERSCORE} # source ${SPACE_TO_UNDERSCORE}
@ -16,10 +16,10 @@ cd "$NOTES_PATH"
git pull >/dev/null 2>&1 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 no changes, exit. Else commit and push with timestamp
if [ "$CHANGES_EXIST" -eq 0 ]; then if [ "$changes_exist" -eq 0 ]; then
echo "No changes" echo "No changes"
exit 0 exit 0
fi fi

View file

@ -5,15 +5,15 @@
# It is aliased to cs-revise in .zshrc # It is aliased to cs-revise in .zshrc
# Choose source directories... # 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... # Return array of all files belonging to source dirs...
for ele in $DIRS_TO_PARSE; do for ele in $directories_to_parse; do
FILE_MATCHES+=( $(find $ele -name "*.md" -type f) ) file_matches+=( $(find $ele -name "*.md" -type f) )
done done
# Generate a random integer between 0 and the match array length... # 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... # Return file matching that index...
echo "Revise this topic: ${FILE_MATCHES[$RANDOM_FILE_INDEX]}" echo "Revise this topic: ${file_matches[$random_file_index]}"